函式功能
創建一個新的桌面與調用進程的當前視窗站,聯營它,並將其分配給調用執行緒。調用進程必須有一個相應的視窗站,無論是在分配過程中創建時的制度或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