CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 20
  1. #1
    Join Date
    Jan 2004
    Posts
    131

    opening a exe file

    How do you open a exe file programmaticaly?
    My program is visual c++ mfc.

  2. #2
    Join Date
    Jul 2003
    Location
    Maryland
    Posts
    762
    What do you mean by "opening" it?

    Running it? If so, you can just include <cstdlib> and use the system() function to run it.

  3. #3
    Join Date
    Jan 2004
    Posts
    131
    that doesnt work and yes how to run a exe.

  4. #4
    Join Date
    Feb 2004
    Posts
    21
    There are some other functions like _spawnl, _spawnp... and _execv, _execve... Look in the MSDN.
    Why system() doesn't work? Try to execute it in a separate thread(for example look _beginthread or (I'm not sure for MFC) afxBeginThread()) and may be will work.
    Last edited by defiler_z; March 4th, 2004 at 06:56 PM.

  5. #5
    Join Date
    Jul 2003
    Location
    Maryland
    Posts
    762
    Originally posted by immortal20
    that doesnt work and yes how to run a exe.
    system works fine, tell us what you did.

  6. #6
    Join Date
    Jul 2002
    Location
    Princeton, NewJersey, US
    Posts
    817
    Try ShellExecute() or CreateProcess() ..
    GOOD DAY..!

    NICK.

    E-MAIL : [email protected]

  7. #7
    Join Date
    Jan 2004
    Posts
    131
    well i included the #include <cstdlib>
    then i used this to run a exec
    system("C:\\Documents and Settings\\BBY Tech\\Desktop\\Fixs DAP 1.0\\spybotsd12.exe");
    and then a msdos window opens and closes right away.

  8. #8
    Join Date
    Feb 2004
    Posts
    21
    Well what the program has to do? Because if it is something small it does it and terminate. If you have to enter some data it should stop and wait you to enter something. Otherwise this : system("C:\\Documents and Settings\\BBY Tech\\Desktop\\Fixs DAP 1.0\\spybotsd12.exe"); is correct.

  9. #9
    Join Date
    Jan 2004
    Posts
    131
    well what i want it to do is when i click on this button it brings the spybot installation program.

  10. #10
    Join Date
    Jan 2004
    Posts
    131
    ok i got it working, now is there a way to get rid of that msdos screen. it says C:\windows\system32\cmd.exe in the title bar.

  11. #11
    Join Date
    Aug 2002
    Location
    Australia
    Posts
    46
    Yes, use CreateProcess (assuming that the exe is not a console based exe of course).

  12. #12
    Join Date
    Jan 2004
    Posts
    131
    wow there is alot of paremeters in there, can you give me and example in code on how to use all of those paremeters.

  13. #13
    Join Date
    Aug 2002
    Location
    Australia
    Posts
    46
    Okay, the last parameters are output structures. Create them and pass them in. Do NOT make them NULL.

    The first parameter should be null (for the time being).
    The second parameter is your command line.
    Third and fourth parameters should be null (for the time being). Fifth parameter - FALSE.
    Sixth parameter - NORMAL_PRIORITY_CLASS
    Seventh paramter - NULL (for the time being)
    Eighth parameter - NULL (for the time being)

    Lookup MSDN if you would like to know what each parameter is/does.

  14. #14
    Join Date
    Jan 2004
    Posts
    131
    CreateProcess(NULL,"C:\\spybotsd12.exe",NULL,NULL,FALSE,NORMAL_PRIORITY_CLASS,FALSE,NULL,NULL,NULL);

    this is giving me an error when i run the program.

  15. #15
    Join Date
    Jan 2004
    Posts
    131
    it dosent take 8 parematers

Page 1 of 2 12 LastLast

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

Featured