Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

win32 console application 1

Status
Not open for further replies.

Sidro

MIS
Sep 28, 2002
197
0
0
US
hi,
does anyone know and have an exemple code that calls or execute another ".EXE" file? This is for a MS C++ 6.0 Thanks in advance.
 
Code:
#include <process.h>  // or  <cstdlib>

int main()
{
    system( "something.exe" );
    return 0;
}
 
I believe that ShellExecute is the preferred way of doing it; CreateProcess and WinExec will also work.

For ShellExecute you need shellapi.h and shell32.lib. It would look like:

ShellExecute(NULL, "open", "asdf.exe", NULL, NULL, SW_SHOWNORMAL);

See also
 
hi,
thanks alot.just what im looking for.
one more thing, do you know how to close or exit the exe?
maybe i can put that in the destructor.thanks in advance.
 
Use TerminateProcess, but to get the process handle you'll have to use ShellExecute or CreateProcess instead of system() to run the exe.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top