OpenDesktopA function (winuser.h)
Opens the specified desktop object.
Syntax
HDESK OpenDesktopA(
[in] LPCSTR lpszDesktop,
[in] DWORD dwFlags,
[in] BOOL fInherit,
[in] ACCESS_MASK dwDesiredAccess
);
Parameters
[in] lpszDesktop
The name of the desktop to be opened. Desktop names are case-insensitive.
This desktop must belong to the current window station.
[in] dwFlags
This parameter can be zero or the following value.
Value | Meaning |
---|---|
|
Allows processes running in other accounts on the desktop to set hooks in this process. |
[in] fInherit
If this value is TRUE, processes created by this process will inherit the handle. Otherwise, the processes do not inherit this handle.
[in] dwDesiredAccess
The access to the desktop. For a list of access rights, see Desktop Security and Access Rights.
Return value
If the function succeeds, the return value is a handle to the opened desktop. When you are finished using the handle, call the CloseDesktop function to close it.
If the function fails, the return value is NULL. To get extended error information, call GetLastError.
Remarks
The calling process must have an associated window station, either assigned by the system at process creation time or set by the SetProcessWindowStation function.
If the dwDesiredAccess parameter specifies the READ_CONTROL, WRITE_DAC, or WRITE_OWNER standard access rights, you must also request the DESKTOP_READOBJECTS and DESKTOP_WRITEOBJECTS access rights.
Note
The winuser.h header defines OpenDesktop as an alias that automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that is not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows 2000 Professional [desktop apps only] |
Minimum supported server | Windows 2000 Server [desktop apps only] |
Target Platform | Windows |
Header | winuser.h (include Windows.h) |
Library | User32.lib |
DLL | User32.dll |
API set | ext-ms-win-ntuser-windowstation-ansi-l1-1-1 (introduced in Windows 10, version 10.0.14393) |