How to programmatically toggle the visibilty of the desktop icons
The following code will toggle the visibility of the desktop icons, and will update the checkmark in the menu when you right click the desktop.
HWND GetDesktopHWND() { HWND hProgman = FindWindow(_T("Progman"), 0); if (hProgman) return FindWindowEx(hProgman, 0, _T("SHELLDLL_DefView"), 0); return NULL; } void ToggleDesktopIcons() { HWND hWndDesktop = GetDesktopHWND(); if (hWndDesktop) SendMessage(hWndDesktop, WM_COMMAND, 0x7402, 0); }