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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to run exe file in c++ code

Status
Not open for further replies.

Vallurupa

Programmer
Oct 17, 2001
38
US
Hi

I have to start exe file in c++ code
Please help me what code should i write.

Thanks

tiaa

tiaacus@yahoo.com
 
ANY C++ program? Well make the classic "Hello World". Heck, MS Visual C++ will make that for you :)
 
Hi crrrazydan
Actually I have to start some other .EXE file through our c++ code. I am making DLL here. If I call dll function that should start outer .exe file. Is there any utility to start any .exe file in the code it self.

Please let me know.

Thanks

Tiaa

tiaacus@yahoo.com
 
type this:


system("cls"); // this uses command cls to clear screen.

// other executables (if in the path) can be used.
 
you can use one of the following code:

CONSOLE APPLICATION:

#include <windows.h>
void main()
{
ShellExecute( NULL, &quot;open&quot;, &quot;path_to_file&quot;, NULL, NULL, SW_SHOWNORMAL );
}

WINDOWS APPLICATION:

#include <windows.h>
#include <shellapi.h>
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
ShellExecute (NULL,&quot;open&quot;,&quot;path_to_file&quot;,NULL,NULL,SW_SHOWNORMAL);
return 0;
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top