There's a win32 api function, GetDesktopWindow()
, which returns a handle of desktop window.
And there's another one - HWND_DESKTOP
macro. I couldn't find official information in MSDN, but it's found in WinUser.h
#define HWND_DESKTOP ((HWND)0)
So, what's difference between them?
HWND_DESKTOP
is only used by MapWindowRect()
to indicate using screen coordinates, as documented on MSDN. You'll notice its value is equal to NULL, which is also listed there. I'm guessing HWND_DESKTOP
came first.
Of course, valid windows cannot be NULL for real, so HWND_DESKTOP
isn't the handle of the desktop window. While I don't know of any real good things you can do with it, the proper way to get the desktop window's handle is with that function.
(For what it's worth, the example for GetDesktopWindow()
uses the returned handle to position a dialog box on screen. I don't know if the current preference is to use the current monitor's work area instead...)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With