你找一下,原来的贴子中有,这是我改成C语言版的。
WORD WinExecAndWait32(String FileName,int Visibility )
{
LPSTARTUPINFO StartupInfo;
LPPROCESS_INFORMATION ProcessInfo;
//GETDIR(0,WorkDir);
//StrPCopy(zCurDir,WorkDir);
//Fillchar(StartupInfo,Sizeof(StartupInfo),#0);
StartupInfo->cb = sizeof(StartupInfo);
StartupInfo->dwFlags = STARTF_USESHOWWINDOW;
StartupInfo->wShowWindow = Visibility;
if (! CreateProcess(NULL,
FileName.c_str(), //{ pointer to command line string }
NULL, //{ pointer to process security attributes }
NULL, //{ pointer to thread security attributes }
false, //{ handle inheritance flag }
CREATE_NEW_CONSOLE | //{ creation flags }
NORMAL_PRIORITY_CLASS,
NULL, //{ pointer to new environment block }
NULL, //{ pointer to current directory name }
StartupInfo, //{ pointer to STARTUPINFO }
ProcessInfo))
return -1; //{ pointer to PROCESS_INF }
else {
WaitForSingleObject(ProcessInfo->hProcess,INFINITE);
LPDWORD Result;
GetExitCodeProcess(ProcessInfo->hProcess,Result);
return *Result;
}