The documentation for the CreateDesktop function on msdn describes the following signature:
HDESK WINAPI CreateDesktop( _In_ LPCTSTR lpszDesktop, _Reserved_ LPCTSTR lpszDevice, _Reserved_ DEVMODE *pDevmode, _In_ DWORD dwFlags, _In_ ACCESS_MASK dwDesiredAccess, _In_opt_ LPSECURITY_ATTRIBUTES lpsa ); I'm interested in the dwDesiredAccess parameter with type ACCESS_MASK : (documentation) .
More specifically, the value of DESKTOP_HOOKCONTROL .
DESKTOP_HOOKCONTROL (0x0008L) Required to establish any of the window hooks. It turns out that it is needed to establish any hook.
Those. if DESKTOP_HOOKCONTROL not, then it will be impossible to install hooks on the newly created desktop? But this is not the case, I checked.
Then what does this parameter mean?
private enum DesktopAccess : uint { DesktopNone = 0, DesktopReadobjects = 0x0001, DesktopCreatewindow = 0x0002, DesktopCreatemenu = 0x0004, DesktopHookcontrol = 0x0008, DesktopJournalrecord = 0x0010, DesktopJournalplayback = 0x0020, DesktopEnumerate = 0x0040, DesktopWriteobjects = 0x0080, DesktopSwitchdesktop = 0x0100, GenericAll = (DesktopReadobjects | DesktopCreatewindow | DesktopCreatemenu // | DesktopHookcontrol | DesktopJournalrecord | DesktopJournalplayback | DesktopEnumerate | DesktopWriteobjects | DesktopSwitchdesktop), } CreateDesktop(nameDesktop, IntPtr.Zero, IntPtr.Zero, 0x0001, (uint)DesktopAccess.GenericAll, IntPtr.Zero); You can find all code here: https://stackoverflow.com/questions/29902715/how-close-all-process-on-new-desktop