本軟件無需界面,實現重啓 explorer.exe進程。
直接上代碼,可以寫到OnInitDialog()函數中。
BOOL CXXXlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
// 設置此對話框的圖標。當應用程序主窗口不是對話框時,框架將自動
// 執行此操作
SetIcon(m_hIcon, TRUE); // 設置大圖標
SetIcon(m_hIcon, FALSE); // 設置小圖標
// TODO: 在此添加額外的初始化代碼
char strShell[1024];
SHELLEXECUTEINFOA shellExeInfo = {0};
shellExeInfo.cbSize = sizeof(SHELLEXECUTEINFOA);
shellExeInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
shellExeInfo.nShow = SW_HIDE;
shellExeInfo.lpVerb = "open";
GetSystemDirectoryA(strShell,1024);
::PathAppendA(strShell,"taskkill.exe");
shellExeInfo.lpFile = strShell;
shellExeInfo.lpParameters = "/F /IM explorer.exe";
ShellExecuteExA(&shellExeInfo);
WaitForSingleObject(shellExeInfo.hProcess,INFINITE);
GetWindowsDirectoryA(strShell,1024);
::PathAppendA(strShell,"explorer.exe");
WinExec(strShell,SW_SHOW);
OnOK();
return TRUE; // 除非將焦點設置到控件,否則返回 TRUE
}