.
Summary
C# Signature:
// ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.WIN32COM.v10.en/dllproc/base/createdesktop.htm
[DllImport("user32.dll", EntryPoint="CreateDesktop", CharSet=CharSet.Unicode, SetLastError=true)]
public static extern IntPtr CreateDesktop(
[MarshalAs(UnmanagedType.LPWStr)] string desktopName,
[MarshalAs(UnmanagedType.LPWStr)] string device, // must be null.
[MarshalAs(UnmanagedType.LPWStr)] string deviceMode, // must be null,
[MarshalAs(UnmanagedType.U4)] int flags, // use 0
[MarshalAs(UnmanagedType.U4)] DESKTOP_ACCESS_MASK accessMask,
[MarshalAs(UnmanagedType.LPStruct)] SecurityAttributes attributes);
// ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.WIN32COM.v10.en/dllproc/base/closedesktop.htm
[DllImport("user32.dll", EntryPoint="CloseDesktop", CharSet = CharSet.Unicode, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CloseDesktop(IntPtr handle);
User-Defined Types:
None.
Notes:
None.
Tips & Tricks:
Please add some!
DesktopClass on dotnet-snippets.de
Sample Code:
public class SafeDesktopHandle : BaseSafeHandle
{
public SafeDesktopHandle(IntPtr handle, bool ownsHandle)
: base(handle, ownsHandle)
{ }
protected override bool CloseNativeHandle(IntPtr handle)
{
return WindowStationAndDesktop.CloseDesktop(handle);
}
}
[Flags]
internal enum DESKTOP_ACCESS_MASK : uint
{
DESKTOP_NONE = 0,
DESKTOP_READOBJECTS = 0x0001,
DESKTOP_CREATEWINDOW = 0x0002,
DESKTOP_CREATEMENU = 0x0004,
DESKTOP_HOOKCONTROL = 0x0008,
DESKTOP_JOURNALRECORD = 0x0010,
DESKTOP_JOURNALPLAYBACK = 0x0020,
DESKTOP_ENUMERATE = 0x0040,
DESKTOP_WRITEOBJECTS = 0x0080,
DESKTOP_SWITCHDESKTOP = 0x0100,
GENERIC_ALL = ( DESKTOP_READOBJECTS | DESKTOP_CREATEWINDOW | DESKTOP_CREATEMENU |
DESKTOP_HOOKCONTROL | DESKTOP_JOURNALRECORD | DESKTOP_JOURNALPLAYBACK |
DESKTOP_ENUMERATE | DESKTOP_WRITEOBJECTS | DESKTOP_SWITCHDESKTOP |
STANDARD_ACCESS.STANDARD_RIGHTS_REQUIRED),
}
Alternative Managed API:
Do you know one? Please contribute it!
Documentation
DesktopClass on dotnet-snippets.de
The CreateDesktop API
4/17/2010 9:34:24 PM - -67.168.202.202
Please edit this page!
Do you have...
helpful tips or sample code to share for using this API in managed code?
corrections to the existing content?
variations of the signature you want to share?
additional languages you want to include?
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).