|
发表于 2020-6-29 15:45:02
|
显示全部楼层
运行指定位置的可执行程序:
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);
//等待子进程的退出
WaitForSingleObject(ProInfo.hProcess, INFINITE);
//获取子进程的退出码
GetExitCodeProcess(ProInfo.hProcess, &ErrorCode);
//关闭子进程句柄
CloseHandle(ProInfo.hProcess); |
|