@羅弘陽
自己寫的一個公共函數(shù)類,上面代碼用到的函數(shù):
/******************************************************************
* 函數(shù)介紹:運行程序
* 輸入參數(shù):
* 輸出參數(shù):
* 返回值 :
*******************************************************************/
DWORD CCommonFun::WinExecAndWait32(LPCTSTR lpszAppPath,
LPCTSTR lpParameters,
LPCTSTR lpszDirectory,
DWORD dwMilliseconds,
BOOL bIsWait,
int nShow)
{
SHELLEXECUTEINFO ShExecInfo = {0};
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
ShExecInfo.hwnd = NULL;
ShExecInfo.lpVerb = NULL;
ShExecInfo.lpFile = lpszAppPath;
ShExecInfo.lpParameters = lpParameters;
ShExecInfo.lpDirectory = lpszDirectory;
ShExecInfo.nShow = nShow; //SW_SHOW
ShExecInfo.hInstApp = NULL;
ShellExecuteEx(&ShExecInfo);
if ( ShExecInfo.hProcess == NULL)
return 1;
if ( !bIsWait )
return 0;
if (WaitForSingleObject(ShExecInfo.hProcess, dwMilliseconds) == WAIT_TIMEOUT)
{
TerminateProcess(ShExecInfo.hProcess, 0);
return 1;
}
DWORD dwExitCode;
BOOL bOK = GetExitCodeProcess(ShExecInfo.hProcess, &dwExitCode);
ASSERT(bOK);
return dwExitCode;
}
回復 更多評論