The easiest way to restart Windows Explorer shell is… sending a TerminateProcess with “2” as exit code.
1 2 3 4 |
HANDLE h_explorer; h_explorer = OpenProcess(PROCESS_TERMINATE, false, pid); TerminateProcess(h_explorer, 2); CloseHandle(h_explorer); |
“pid” is your Process ID. Since explorer.exe may have multiple processes, you’ll need the one who has “Shell_TrayWnd” Window Class name.
Small example:
1 2 3 |
HWND hwnd = FindWindow(L"Shell_TrayWnd", NULL); DWORD pid = {}; GetWindowThreadProcessId(hwnd, &pid); |
Easy, right?
Why is your Twitter deleted?
Is it the best way to terminate any process or explorer only?
Why do You send 2? What does it mean?
This just for explorer.exe shell.
Terminate process with 2 tells to the OS (not sure exactly how, but this is how it works when you register explorer.exe as shell) to restart the process
When is Dynamic Shell coming out?
Thank you!!1