使用CreateDesktop最多能创建多少个虚拟桌面?
部分代码:
CString tDeskName;
for(int i=1; i<100; ++i)
{
tDeskName.Format(_T("testvd_%d"), i);
HDESK tDesk = OpenDesktop(tDeskName, DF_ALLOWOTHERACCOUNTHOOK, TRUE, GENERIC_ALL);
if(NULL == tDesk)
{
   SECURITY_ATTRIBUTES sAttribute = {sizeof(SECURITY_ATTRIBUTES), NULL, TRUE};
   tDesk = CreateDesktop(tDeskName, NULL, NULL, DF_ALLOWOTHERACCOUNTHOOK, GENERIC_ALL, &sAttribute);   if(NULL == tDesk)
   {
LPVOID lpMsgBuf;
LPVOID lpDisplayBuf;
DWORD dw = GetLastError();  FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER | 
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
dw,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf,
0, NULL ); lpDisplayBuf = (LPVOID)LocalAlloc(LMEM_ZEROINIT, 1024); 
StringCchPrintf((LPTSTR)lpDisplayBuf, 
LocalSize(lpDisplayBuf),
TEXT("创建桌面%d失败:  %s"), i+1, lpMsgBuf); 
MessageBox((LPCTSTR)lpDisplayBuf, TEXT("error"), MB_ICONERROR | MB_TOPMOST | MB_TASKMODAL);  LocalFree(lpMsgBuf);
LocalFree(lpDisplayBuf); break;
   }
   tDeskName.ReleaseBuffer();
  }
 CloseDesktop(tDesk);
}

解决方案 »

  1.   

    The number of desktops that can be created is limited by the size of the system desktop heap, which is 48 MB. 
      

  2.   

     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=16The first SharedSection value is the size of the shared heap common 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.
      

  3.   

    改注册表有时候explorer.exe进程异常.
    不过可能是最好的办法了.
    结贴.