Results 1 to 8 of 8

Thread: Run a file from my program?

  1. #1
    Ragnar
    Guest

    Run a file from my program?

    I have created an MFC EXE and I have added a button. Now I want IExplorer.exe to open when I click the button. The same as Shell("IExplorer.exe") in VB.

    void CTestDlg::OnOpenButton()
    {
    // open iexplorer.exe code
    }

    How can I do this?

  2. #2
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238
    try this...

    PHP Code:
       ShellExecute(hDlg"open""IExplorer.exe"NULLNULLSW_SHOWNORMAL); 

  3. #3
    Ragnar
    Guest
    Hmm that didn't work. It gave me a error at the Dlg parameter. I don't have that identifier identified. I tried to NULL and it compiled successfully but nothing happend in the program.
    What shall I do

  4. #4
    Junior Member
    Join Date
    Jun 2001
    Posts
    22
    well if you're trying to run Internet Explorer, you need to execute iexplore.exe .. you may also have to supply the path.

    additionally, if the return value of ShellExecute is <32 there was an error...

  5. #5
    Ragnar
    Guest
    What do you mean I have to execute it? Thats the problem I'm having
    I want to be able to execute other programs from my program.
    ShellExecute doesn't seem to work, hmm..
    Let's say I want to execute test.exe from my program and test.exe is in the same directory as my program, how would I do?

  6. #6
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    Try:
    Code:
    WinExec("test.exe",SW_SHOW);
    However it is a lot better to use the ShellExecute API.
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  7. #7
    Junior Member
    Join Date
    Jun 2001
    Posts
    22
    ShellExecute(hwnd, "test.exe", 0, 0, SW_SHOW)

    don't use WinExec() ... it's kept for 16-bit compatibility only...


    for more information check out the MSDN Library @ msdn.microsoft.com

  8. #8
    Ragnar
    Guest
    Ahh thanks alot guys! It works now.
    Thanks again.

Posting Permissions

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



Click Here to Expand Forum to Full Width