The CreateDesktop function creates a new desktop, associates it with the current window station of the calling process, and assigns it to the calling thread. The calling process must have an associated window station, either assigned by the system at process creation time or set by the SetProcessWindowStation function.
To specify the size of the heap for the desktop, use the CreateDesktopEx function.
CreateDesktop 函数创建一个新的Desktop对象,关联到当前调用进程所在的窗口站中,并且分配给当前调用线程。调用进程必须有一个关联的窗口站对象,一般是由系统在进程创建时分配的或是通过调用SetProcessWindowStation 设置的。如果想指定窗口堆的大小,可以调用CreateDesktopEx 函数。
HDESK CreateDesktop( LPCTSTR lpszDesktop, LPCTSTR lpszDevice, LPDEVMODE pDevmode, DWORD dwFlags, ACCESS_MASK dwDesiredAccess, LPSECURITY_ATTRIBUTES lpsa );
Value | Meaning |
---|---|
DF_ALLOWOTHERACCOUNTHOOK 0x0001 |
Enables processes running in other accounts on the desktop to set hooks in this process.运行于其它账户的进行在当前Desktop对象中设置Hook。 |
This parameter must include the DESKTOP_CREATEWINDOW access right, because internally CreateDesktop uses the handle to create a window.
访问权限标志,值列表请参考:安全与访问权限。
这个参数必须包含:DESKTOP_CREATEWINDOW 权限,因为在CreateDesktop 内部会自动创建一个窗口。
The lpSecurityDescriptor member of the structure specifies a security descriptor for the new desktop. If this parameter is NULL, the desktop inherits its security descriptor from the parent window station.
SECURITY_ATTRIBUTES 结构指针,决定是否可以被子进程继承的句柄。如果为NULL,则句柄不可被继承。
这个结果的 lpSecurityDescriptor 成员属性 指定新的安全描述符给新的Desktop。如果为NULL,新建的Desktop将继承所属窗口站的安全描述符。
If the function succeeds, the return value is a handle to the newly created desktop. If the specified desktop already exists, the function succeeds and returns a handle to the existing 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.
函数调用成功,返回最新的被创建的Desktop对象的句柄,如果指定的Desktop已经存在,并且函数调用成功就返回存在的Desktop的句柄。
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.
The number of desktops that can be created is limited by the size of the system desktop heap, which is 48 MB. Desktop objects use the heap to store resources. You can increase the number of desktops that can be created by reducing the default heap reserved for each desktop in the interactive window station. This value is specified in the SharedSection substring of the following registry value: HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/Session Manager/SubSystems/Windows. The default data for this registry value is as follows:
%SystemRoot%/system32/csrss.exe ObjectDirectory=/Windows SharedSection=1024,3072,512 Windows=On SubSystemType=Windows ServerDll=basesrv,1 ServerDll=winsrv:UserServerDllInitialization,3 ServerDll=winsrv:ConServerDllInitialization,2 ProfileControl=Off MaxRequestThreads=16
Client | Requires Windows Vista, Windows XP, Windows 2000 Professional, or Windows NT Workstation 3.51 and later. |
---|---|
Server | Requires Windows Server "Longhorn", Windows Server 2003, Windows 2000 Server, or Windows NT Server 3.51 and later. |
Header | Declared in Winuser.h; include Windows.h. |
Library | Link to User32.lib. |
DLL | Requires User32.dll. |
Unicode | Implemented as CreateDesktopW (Unicode) and CreateDesktopA (ANSI). |
Desktops, Window Station and Desktop Functions, CloseDesktop, CreateDesktopEx, SECURITY_ATTRIBUTES, SetProcessWindowStation, SwitchDesktop