What is the difference between the GetDesktopWindow and OpenInputDesktop APIs in Windows?

后端 未结 2 1286
梦毁少年i
梦毁少年i 2020-12-31 12:34

What is the usage difference between the GetDesktopWindow and OpenInputDesktop APIs in Windows?

2条回答
  •  清歌不尽
    2020-12-31 12:55

    They return completely different values, so they are not interchangeable. You can tell just by looking at their function signatures in the documentation:

    GetDesktopWindow returns an HWND, which is a handle to a window:

    HWND WINAPI GetDesktopWindow(void);
    

    while OpenInputDesktop returns an HDESK, which is a handle to a desktop:

    HDESK WINAPI OpenInputDesktop(
      __in  DWORD dwFlags,
      __in  BOOL fInherit,
      __in  ACCESS_MASK dwDesiredAccess
    );
    

    Therefore, which one you use would obviously depend on which type of value you needed. All of the Desktop functions require parameters of type HDESK. All window manipulation functions are going to require handles to a window (HWND).

    All of that said, I would be remiss if I didn't caution you against abusing the desktop window, as returned by the GetDesktopWindow function. The desktop window is very special.

提交回复
热议问题