Gracefully Exit Explorer (Programmatically)

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.

Leave a Comment