标题：CreateDesktopA
函数功能
创建一个新的桌面与调用进程的当前窗口站，联营它，并将其分配给调用线程。调用进程必须有一个相应的窗口站，无论是在分配过程中创建时的制度或SetProcessWindowStation函数集。 
指定为桌面堆的大小，使用CreateDesktopEx功能。
语法
C++语法HDESK WINAPI CreateDesktop(
__in        LPCTSTR lpszDesktop,
__reserved  LPCTSTR lpszDevice,
__reserved  LPDEVMODE pDevmode,
__in        DWORD dwFlags,
__in        ACCESS_MASK dwDesiredAccess,
__in_opt    LPSECURITY_ATTRIBUTES lpsa
);
易语言语法.版本 2
.DLL命令 CreateDesktopA,整数型,"user32.dll","CreateDesktopA",,
.参数 lpszDesktop,文本型, ,桌面的名称创建。桌面名称是区分大小写，并且不能包含反斜杠字符(\)。
.参数 lpszDevice,文本型, ,版权所有;必须为NULL。 
.参数 pDevmode,DEVMODE, ,版权所有;必须为NULL。 
.参数 dwFlags,整数型, ,此参数可以是零或以下的价值。 ValueMeaning DF_ALLOWOTHERACCOUNTHOOK 0x0001Enables进程中的其他帐户运行在桌面上设置钩子在这一进程中。 
.参数 dwDesiredAccess,整数型, ,dwDesiredAccess [in] 到桌面访问。对于一个值列表，请参阅桌面安全和访问权限。 此参数必须包括DESKTOP_CREATEWINDOW访问权，因为国内CreateDesktop使用句柄创建一个窗口。
.参数 lpsa,SECURITY_ATTRIBUTES, ,一个 SECURITY_ATTRIBUTES结构，决定是否返回的句柄可以被继承的子进程的指针。如果lpsa为NULL，则句柄不能被继承。
参数
lpszDesktop [in] 
桌面的名称创建。桌面名称是区分大小写，并且不能包含反斜杠字符(\)。 
lpszDevice 
版权所有;必须为NULL。 
pDevmode 
版权所有;必须为NULL。 
dwFlags [in] 
此参数可以是零或以下的价值。 
ValueMeaning 
DF_ALLOWOTHERACCOUNTHOOK 
0x0001Enables进程中的其他帐户运行在桌面上设置钩子在这一进程中。
dwDesiredAccess [in] 
到桌面访问。对于一个值列表，请参阅桌面安全和访问权限。 
此参数必须包括DESKTOP_CREATEWINDOW访问权，因为国内CreateDesktop使用句柄创建一个窗口。 
lpsa [中，可选] 
一个 SECURITY_ATTRIBUTES结构，决定是否返回的句柄可以被继承的子进程的指针。如果lpsa为NULL，则句柄不能被继承。 
结构的lpSecurityDescriptor成员指定为新的桌面安全描述符。如果该参数为NULL，桌面继承父窗口站的安全描述符。 
返回值 
如果函数成功，返回值是一个句柄到新创建的桌面上。如果指定的桌面上已经存在，函数成功并返回的句柄现有的桌面。当您使用完的处理，调用CloseDesktop函数将其关闭。 
如果函数失败，返回值为NULL。为了获得更多错误信息，调用GetLastError。 
备注
如果dwDesiredAccess参数指定次数READ_CONTROL，WRITE_DAC，或WRITE_OWNER标准访问权限，您还必须要求DESKTOP_READOBJECTS和DESKTOP_WRITEOBJECTS访问权限。 
在可以创建的计算机数量是有限的系统桌面堆，这是48 MB的大小。桌面对象使用的堆存储资源。您可以增加数量的台式机，可以通过减少默认堆的每个桌面交互窗口站预留创建。指定此值在以下注册表值的SharedSection子项：HKEY_LOCAL_MACHINE \系统\ CurrentControlSet \控制\ Session Manager的\子系统\窗口。此注册表值的默认数据如下： 
的%SystemRoot%\ system32 \ csrss.exe ObjectDirectory = \视窗的SharedSection = 1024,3072,512视窗=在SubSystemType =视窗ServerDll = basesrv，1 ServerDll = winsrv：UserServerDllInitialization，3 ServerDll = winsrv：ConServerDllInitialization，MaxRequestThreads 2 ProfileControl =关闭= 16 
为的SharedSection子的值描述如下： 
第一的SharedSection值是堆共享共同的台式机，以千字节大小。 
第二个的SharedSection值是衡量每一项是在交互窗口站，WinSta0千字节为单位，创建桌面所需的桌面堆的大小。 
在第三个SharedSection值是衡量每一项在一个交互式窗口站创建桌面千字节为单位，需要在桌面上堆的大小。 
要求
最低支持：client－Windows 2000专业版 
最低支持server－Windows 2000服务器
HeaderWinuser. h(头文件：winuser.h) 
LibraryUser32.lib 
DLLUser32.dll 
Unicode和ANSI namesCreateDesktopW(Unicode)和CreateDesktopA(ANSI)的 
参见 
CloseDesktop 
CreateDesktopEx 
台式机 
SECURITY_ATTRIBUTES 
SetProcessWindowStation 
SwitchDesktop 
窗口站和桌面功能 
如果有任何问题和意见，请发送给微软
英文原文==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.
use the CreateDesktopEx function.
Syntax
C++ 
HDESK WINAPI CreateDesktop(
__in        LPCTSTR lpszDesktop,
__reserved  LPCTSTR lpszDevice,
__reserved  LPDEVMODE pDevmode,
__in        DWORD dwFlags,
__in        ACCESS_MASK dwDesiredAccess,
__in_opt    LPSECURITY_ATTRIBUTES lpsa
);
Parameters
lpszDesktop [in] 
The name of the desktop to be created. Desktop names are case-insensitive and may not contain backslash characters (\).
lpszDevice 
Reserved; must be NULL.
pDevmode 
Reserved; must be NULL.
dwFlags [in] 
This parameter can be zero or the following value.
ValueMeaning
DF_ALLOWOTHERACCOUNTHOOK
0x0001Enables processes running in other accounts on the desktop to set hooks in this process.
dwDesiredAccess [in] 
The access to the desktop. For a list of values, see Desktop Security and Access Rights . 
This parameter must include the DESKTOP_CREATEWINDOW access right, because internally CreateDesktop uses the handle to create a window.
lpsa [in, optional] 
A pointer to a SECURITY_ATTRIBUTES structure that determines whether the returned handle can be inherited by child processes. If lpsa is NULL, the handle cannot be inherited. 
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.
Return Value
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 .
Remarks
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
The values for the SharedSection substring are described as follows:
The first SharedSection value is the size of the shared heap 
mon to all desktops, in kilobytes. 
The second SharedSection value is the size of the desktop heap needed for each desktop that is created in the interactive window station, WinSta0, in kilobytes. 
The third SharedSection value is the size of the desktop heap needed for each desktop that is created in a noninteractive window station, in kilobytes. 
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinuser.h (include Windows.h)
LibraryUser32.lib
DLLUser32.dll
Unicode and ANSI namesCreateDesktopW (Unicode) and CreateDesktopA (ANSI)
See Also
CloseDesktop 
CreateDesktopEx 
Desktops 
SECURITY_ATTRIBUTES 
SetProcessWindowStation 
SwitchDesktop 
Window Station and Desktop Functions 
Send Comments about this topic to Microsoft
Build date: 8/27/2009