Hi,
I have searched the forums and across google, for code to simply lauch another exe.
Help appreciated
Printable View
Hi,
I have searched the forums and across google, for code to simply lauch another exe.
Help appreciated
There's an entry in the FAQ (there's a "FAQ" button at the top of this page) that does exactly what you're looking for.
How do I run a program from within a program?
**Beaten by Salem.
this should work , only need to add #include <windows.h> at beginning.
an exemple : Exec( "C:\\temp\\hello.exe" );Code:int Exec(char szPath[])
{
PROCESS_INFORMATION pif;
STARTUPINFO si;
ZeroMemory(&si,sizeof(si));
si.cb = sizeof(si);
BOOL bRet = CreateProcess(szPath,NULL,NULL,NULL,FALSE,0,NULL,NULL,&si,&pif);
if (bRet == FALSE) {
MessageBox(HWND_DESKTOP,"Unable to start program","",MB_OK);
return 1;
}
CloseHandle(pif.hProcess);
CloseHandle(pif.hThread);
return 0;
}
do not forget the double \ , or it's will not work.
thanks, slilly me lol the tutorials were the only places that i didnt check. The tutorials seemed very complex to look at so i am goin to try you reply wejav 2nite tand then i will get back to you.
I do not no y this code does not work.
any ideas??Code:#include <windows.h>
int Exec(char szPath[])
{
PROCESS_INFORMATION pif;
STARTUPINFO si;
ZeroMemory(&si,sizeof(si));
si.cb = sizeof(si);
BOOL bRet = CreateProcess(szPath,NULL,NULL,NULL,FALSE,0,NULL,NULL,&si,&pif);
if (bRet == FALSE) {
MessageBox(HWND_DESKTOP,"Unable to start program","",MB_OK);
return 1;
}
CloseHandle(pif.hProcess);
CloseHandle(pif.hThread);
return 0;
}
Exec( "C:\\Dev-Cpp\\madness2.exe" );
Try putting the Exec("C:\\ ... line inside main()...
cant believe i missed that lol.
yep, that works now.
thanks for the help.