Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Senior Coder
    Join Date
    Jun 2002
    Location
    UK
    Posts
    1,137
    Thanks
    0
    Thanked 0 Times in 0 Posts

    VB /C++ tutorials

    does anyone know of any VB/C++ tutorials which will teach me how i can link a button to a program. So when the button labeled notepad is clicked it opens C:\blah\notepad.exe
    i`m interessed in using either one of the two languages for it.
    do you understand?

    thanks in advance

    scroots
    Spammers next time you spam me consider the implications:
    (1) that you will be persuaded by me(in a legitimate mannor)
    (2)It is worthless to you, when i have finished

  • #2
    Regular Coder
    Join Date
    Jul 2002
    Location
    Belgium
    Posts
    124
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I assume you're programming for windows:
    Try this:
    Code:
    switch(LOWORD(wParam))
    {		
    case BUTTON:
          ShellExecute(hwnd,"open","c:\\winnt\\system32\\notepad.exe",NULL,NULL,SW_MAXIMIZE);
    return 0;
    }

    if you're programming for the console (I think this also works in linux)
    you can also use
    Code:
    #include <process.h>
    ...
    spawnl(_P_WAIT,"c:\\winnt\\system32\\notepad.exe","c:\\winnt\\system32\\notepad.exe",NULL);

    - Maes

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Location
    UK
    Posts
    1,137
    Thanks
    0
    Thanked 0 Times in 0 Posts
    maes could you expalin a little deeper.

    scroots
    Spammers next time you spam me consider the implications:
    (1) that you will be persuaded by me(in a legitimate mannor)
    (2)It is worthless to you, when i have finished

  • #4
    Regular Coder
    Join Date
    Jul 2002
    Location
    Belgium
    Posts
    124
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well, when you're makeing a win32 (C) aplication, I advice you to use ShellExecute .

    With ShellExecute, you can start an other program or an other document, print it, etc.
    the first parameter is the Handle to your window (HWND)

    the second: this is what you want to do with the program/document. we want to "open" it. this will execute the .exe-file.

    the third: this is the file (+path) we want to execute.
    you have to youse "\\" instead of '\' beacause the slash (or backslash whatever) is an escape character

    fourth: these are the parameters you want to give to your exe program. I've used NULL here this means I don't want to pass any arguments. but you can type here a path to a .txt-file that you want notepad to open

    fifth: this is the default directory. when you add an .txt-file as the fourth parameter, you can specifie here where notepad has to look for it.

    sixth: this specifies how the program will be shown to you.
    I used SW_MAXIMIZE: this will maximize notedpad.
    SW_MINIMIZE will minimize notepad. there are some more styles, but these are the most important ones (IMHO)


    Am I makeing any sense here?

  • #5
    Senior Coder
    Join Date
    Jun 2002
    Location
    UK
    Posts
    1,137
    Thanks
    0
    Thanked 0 Times in 0 Posts
    are there any tutorials on this, as i am not the worlds best c++/VB programmer, infact i don`t know much at all.
    or what should my code look like?
    cheers
    scroots
    Spammers next time you spam me consider the implications:
    (1) that you will be persuaded by me(in a legitimate mannor)
    (2)It is worthless to you, when i have finished

  • #6
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,040
    Thanks
    10
    Thanked 92 Times in 90 Posts
    PHP Code:
    <?
    #include <shlobj.h>
    #include <shlwapi.h>

    #define YAKS "C:\\WINNT\\NOTEPAD.EXE"

    main()
    {
        
    HWND handle;
        
    ShellExecute(handle,"open",YAKS,NULL,NULL,SW_SHOWNORMAL);

        return 
    0;
    }
    ?>
    lol - just wanted to see what the PHP syntax highlighting did to C
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #7
    New to the CF scene
    Join Date
    Jul 2005
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Is it possible to use a relative path?



    Is there a way to use a relative path, instead of writing the complete path?

    For example, if I have a executable.exe file in a folder

    Can I use:

    "folder\\executable.exe"

    instead of

    "d:\\folder\\executable.exe"

    ?

    Because I´m gonna save the program that calls the file "executable.exe" in a CD, and the drive could have another letter assigned instead of "d:"

    Thanks


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •