在控制台程序的函数中使用ExitProcess函数,退出函数,调用者接收返回值:
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);
//被调用进程用ExitProcess(0)返回指定的值
调用控制台注册组件
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);
}
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。