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.

119 lines
2.2 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name :
  4. isplat.cxx
  5. Abstract:
  6. This module defines functions for determining platform types
  7. Author:
  8. Johnson Apacible (johnsona) 19-Nov-1996
  9. --*/
  10. #include <nt.h>
  11. #include <ntrtl.h>
  12. #include <nturtl.h>
  13. #include <windows.h>
  14. #include <inetsvcs.h>
  15. PLATFORM_TYPE TsPlatformType = PtInvalid;
  16. typedef
  17. BOOLEAN
  18. (NTAPI *GET_PRODUCT_TYPE)(
  19. PNT_PRODUCT_TYPE
  20. );
  21. PLATFORM_TYPE
  22. IISGetPlatformType(
  23. VOID
  24. )
  25. /*++
  26. This function consults the registry and determines the platform type
  27. for this machine.
  28. Arguments:
  29. None
  30. Returns:
  31. Platform type
  32. --*/
  33. {
  34. PLATFORM_TYPE pt;
  35. LONG result;
  36. HKEY keyHandle;
  37. WCHAR productType[30];
  38. DWORD type;
  39. BOOL isNt = TRUE;
  40. OSVERSIONINFO osInfo;
  41. //
  42. // See if the platform type has already been discovered.
  43. //
  44. if ( TsPlatformType != PtInvalid ) {
  45. return(TsPlatformType);
  46. }
  47. //
  48. // see if this is win95
  49. //
  50. osInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
  51. if ( GetVersionEx( &osInfo ) ) {
  52. isNt = (osInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
  53. } else {
  54. IIS_PRINTF((buff,"GetVersionEx failed with %d\n",
  55. GetLastError()));
  56. }
  57. if ( isNt ) {
  58. HINSTANCE hNtdll;
  59. NT_PRODUCT_TYPE ntType;
  60. GET_PRODUCT_TYPE pfnGetProductType;
  61. //
  62. // Get the product type from the system
  63. //
  64. pt = PtNtWorkstation;
  65. hNtdll = LoadLibrary("ntdll.dll");
  66. if ( hNtdll != NULL ) {
  67. pfnGetProductType = (GET_PRODUCT_TYPE)
  68. GetProcAddress(hNtdll, "RtlGetNtProductType");
  69. if ( (pfnGetProductType != NULL) &&
  70. pfnGetProductType( &ntType ) ) {
  71. if ( (ntType == NtProductLanManNt) ||
  72. (ntType == NtProductServer) ) {
  73. pt = PtNtServer;
  74. }
  75. }
  76. FreeLibrary( hNtdll );
  77. }
  78. } else {
  79. pt = PtWindows95;
  80. }
  81. TsPlatformType = pt;
  82. return(pt);
  83. } // IISGetPlatformType