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.

84 lines
2.6 KiB

  1. //+----------------------------------------------------------------------------
  2. //
  3. // File: nativecm.cpp
  4. //
  5. // Module: CMSETUP.LIB
  6. //
  7. // Synopsis: Implementation of the CmIsNative function.
  8. //
  9. // Copyright (c) 1999 Microsoft Corporation
  10. //
  11. // Author: quintinb Created 01/14/99
  12. //
  13. //+----------------------------------------------------------------------------
  14. #include "cmsetup.h"
  15. #include "reg_str.h"
  16. //+----------------------------------------------------------------------------
  17. //
  18. // Function: CmIsNative
  19. //
  20. // Synopsis: This function Returns TRUE if CM is native to the current OS.
  21. //
  22. // Arguments: None
  23. //
  24. // Returns: BOOL - TRUE if CM is native.
  25. //
  26. // History: Created Header 1/17/99
  27. // quintinb NTRAID 364533 -- Changed IsNative so that Win98 SE won't be
  28. // considered Native even if CmNative is set to 1. See below
  29. // and the bug for details.
  30. //
  31. //+----------------------------------------------------------------------------
  32. BOOL CmIsNative()
  33. {
  34. static BOOL bCmNotNative = -1;
  35. if (-1 == bCmNotNative)
  36. {
  37. const TCHAR* const c_pszRegCmNative = TEXT("CmNative");
  38. HKEY hKey;
  39. DWORD dwCmNative;
  40. ZeroMemory(&dwCmNative, sizeof(DWORD));
  41. if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, c_pszRegCmAppPaths, 0, KEY_READ, &hKey))
  42. {
  43. DWORD dwSize = sizeof(DWORD);
  44. DWORD dwType = REG_DWORD;
  45. if (ERROR_SUCCESS == RegQueryValueEx(hKey, c_pszRegCmNative, NULL, &dwType,
  46. (LPBYTE)&dwCmNative, &dwSize))
  47. {
  48. CPlatform cmplat;
  49. if (cmplat.IsWin98Sr())
  50. {
  51. //
  52. // We no longer want Win98 SE to be native even though the key was set and
  53. // CM is a system component. However, we may want to give ourselves an out
  54. // someday so if CmNative is set to 2 on win98 SE we will still consider it Native.
  55. // We hopefully will never need this but we might.
  56. //
  57. bCmNotNative = (2 != dwCmNative);
  58. }
  59. else
  60. {
  61. bCmNotNative = (dwCmNative ? 0 : 1);
  62. }
  63. }
  64. else
  65. {
  66. bCmNotNative = 1;
  67. }
  68. RegCloseKey(hKey);
  69. }
  70. else
  71. {
  72. bCmNotNative = 1;
  73. }
  74. }
  75. return !bCmNotNative;
  76. }