Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

90 lines
2.4 KiB

  1. /*++
  2. Copyright (c) 2001 Microsoft Corporation
  3. Module Name:
  4. shell.c
  5. Abstract:
  6. This module contains code to set the shell optimizations based on the system's physical memory
  7. [ComputerSettings]
  8. OptimizeShell = YES | NO - Overides the default optimization. The default is based on the amount of
  9. physical memory on the system. If the system has less than MIN_MEMORY MB of memory
  10. the default for this key will be NO, otherwise, it will be YES.
  11. Author:
  12. Stephen Lodwick (stelo) 05/2001
  13. Revision History:
  14. --*/
  15. //
  16. // Include File(s):
  17. //
  18. #include "factoryp.h"
  19. //
  20. // Defined Value(s):
  21. //
  22. #define MIN_MEMORY 84 // Used 84MB because system may have 96MB but the memory function reports less (video memory)
  23. #define REG_KEY_FASTUSERS _T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon")
  24. #define REG_VAL_MULTISES _T("AllowMultipleTSSessions")
  25. BOOL OptimizeShell(LPSTATEDATA lpStateData)
  26. {
  27. BOOL bRet = TRUE;
  28. MEMORYSTATUSEX mStatus;
  29. DWORD dwSetting = 0;
  30. // Do not continue if the user did not want to optimize the shell (optimize if there is no setting)
  31. //
  32. if ( !IniSettingExists(lpStateData->lpszWinBOMPath, INI_SEC_WBOM_SETTINGS, INI_KEY_WBOM_OPT_SHELL, INI_VAL_WBOM_NO) )
  33. {
  34. // Zero out the memory
  35. //
  36. ZeroMemory(&mStatus, sizeof(mStatus));
  37. // Fill in required values
  38. //
  39. mStatus.dwLength = sizeof(mStatus);
  40. // Determine the default value for shell optimization
  41. //
  42. if ( GlobalMemoryStatusEx(&mStatus) )
  43. {
  44. // Determine if the amount of memory on the system is enough
  45. //
  46. if ( (mStatus.ullTotalPhys / (1024 * 1024)) >= MIN_MEMORY )
  47. {
  48. dwSetting = 1;
  49. }
  50. // Set the value based on the memory
  51. //
  52. bRet = RegSetDword(HKLM, REG_KEY_FASTUSERS, REG_VAL_MULTISES, dwSetting);
  53. }
  54. else
  55. {
  56. // There was an error retrieving the memory status
  57. //
  58. bRet = FALSE;
  59. }
  60. }
  61. return bRet;
  62. }
  63. BOOL DisplayOptimizeShell(LPSTATEDATA lpStateData)
  64. {
  65. return ( !IniSettingExists(lpStateData->lpszWinBOMPath, INI_SEC_WBOM_SETTINGS, INI_KEY_WBOM_OPT_SHELL, INI_VAL_WBOM_NO) );
  66. }