|
Run the executable program at the specified location:
STARTUPINFO StartupInfo;
PROCESS_INFORMATION ProInfo;
DWORD ErrorCode;
memset(&StartupInfo,0,sizeof(STARTUPINFO));
StartupInfo.cb=sizeof(STARTUPINFO);
StartupInfo.lpReserved=NULL;
StartupInfo.lpDesktop=NULL;
StartupInfo.lpTitle=NULL;
StartupInfo.dwFlags=STARTF_USESHOWWINDOW;
StartupInfo.cbReserved2=0;
StartupInfo.lpReserved2=NULL;
StartupInfo.wShowWindow=SW_SHOWNORMAL;
bool bReturn=CreateProcess(NULL,"c:\\windows\\notepad.exe",NULL,
NULL, FALSE, 0, NULL, NULL,&StartupInfo,&ProInfo);
ErrorCode=GetLastError();
CloseHandle(ProInfo.hThread);
//Wait for the exit of the child process
WaitForSingleObject(ProInfo.hProcess, INFINITE);
//Get the exit code of the child process
GetExitCodeProcess(ProInfo.hProcess,&ErrorCode);
//Close the child process handle
CloseHandle(ProInfo.hProcess); |
|