溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

獲取控制臺(tái)程序的返回值

發(fā)布時(shí)間:2020-07-10 12:26:03 來源:網(wǎng)絡(luò) 閱讀:873 作者:Chinayu2014 欄目:編程語言

在控制臺(tái)程序的函數(shù)中使用ExitProcess函數(shù),退出函數(shù),調(diào)用者接收返回值:

	DWORD nResult;
	SHELLEXECUTEINFO ShExeInfo = { 0 };
	ShExeInfo.cbSize = sizeof(SHELLEXECUTEINFO);
	ShExeInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
	ShExeInfo.hwnd = NULL;
	ShExeInfo.lpVerb = NULL;
	ShExeInfo.lpFile = _T("a.exe");
	ShExeInfo.lpParameters = _T(" 1");
	ShExeInfo.lpDirectory = NULL;
	ShExeInfo.nShow = SW_HIDE;
	ShExeInfo.hInstApp = NULL;
	ShellExecuteEx(&ShExeInfo);
	WaitForSingleObject(ShExeInfo.hProcess, 1000 * 120);
	GetExitCodeProcess(ShExeInfo.hProcess, &nResult);
	//被調(diào)用進(jìn)程用ExitProcess(0)返回指定的值

調(diào)用控制臺(tái)注冊(cè)組件

VOID RegisterReportCom()
{
	SHELLEXECUTEINFO ShExecInfo = { 0 };
	ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
	ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
	ShExecInfo.hwnd = NULL;
	ShExecInfo.lpVerb = _T("runas");

	ShExecInfo.lpFile = _T("C:/Windows/SysWOW64/regsvr32.exe");

	CString  strPath  = GetApplicationPath()+ _T("gregn6.dll /s");
	ShExecInfo.lpParameters = strPath ;

	ShExecInfo.lpDirectory  = NULL;
	ShExecInfo.nShow        = SW_HIDE;
	ShExecInfo.hInstApp     = NULL;

	ShellExecuteEx(&ShExecInfo);

	strPath = GetApplicationPath() + _T("grdes6.dll /s");
	ShExecInfo.lpParameters = strPath ;
	ShellExecuteEx(&ShExecInfo);
}


向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI