Gracefully Exit Explorer (Programmatically)
exit, explorer, winapi, windows
Solution
I debugged this out of curiosity. All it does is post a message to one of explorer's windows:
BOOL ExitExplorer()
{
HWND hWndTray = FindWindow(_T("Shell_TrayWnd"), NULL);
return PostMessage(hWndTray, 0x5B4, 0, 0);
}
Of course this is an undocumented WM_USER message so the behavior could quite possibly change in the future.
Problem
How do you gracefully close Explorer programmatically? By that I mean, how do you invoke this function programmatically: Edit: Typo in the picture, it should say "Ctrl-Shift-Right-Click" instead of "Shift-Click".