Einzelnen Beitrag anzeigen

Benutzerbild von Codehunter
Codehunter

Registriert seit: 3. Jun 2003
Ort: Thüringen
2.272 Beiträge
 
Delphi 10.4 Sydney
 
#13

AW: Falscher Product Type in OSVersionInfoEx

  Alt 13. Dez 2012, 15:01
In letzter Zeit diskutieren wir hier aber ständig irgendwelche Lizenzfragen...

Zum Thems: Hier mal ein Auszug aus meinem DelphiWorks 1.5 Beta (wobei ich noch nicht dazu gekommen bin, Windows 8 und seine Varianten einzupflegen):
Delphi-Quellcode:
function dwGetOS: TDWOSType;
var
   OSV: TOSVersionInfoEx;
   SI: TSystemInfo;
begin
   dwGetWindowsVersionEx(OSV);
   ZeroMemory(@SI, SizeOf(TSystemInfo));
   GetSystemInfo(SI);
   result:= OS_UNKNOWN;
   if OSV.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS then begin
      case OSV.dwMinorVersion of
        0:
          case (OSV.dwBuildNumber and $FFFF) of
            950:
              if (UpperCase(OSV.szCSDVersion) = 'A') then
                result:= OS_WIN95A
              else
                result:= OS_WIN95;
            1111:
              result:= OS_WIN95OSR2A;
            else
              result:= OS_WIN95;
          end; // case (OSV.dwBuildNumber and $FFFF)
        3:
          if (UpperCase(OSV.szCSDVersion) = 'B') then
            result:= OS_WIN95OSR2B
          else
            result:= OS_WIN95OSR2C;
        10:
          case (OSV.dwBuildNumber and $FFFF) of
            1998:
              result:= OS_WIN98;
            2222:
              result:= OS_WIN98SE;
            else
              result:= OS_WIN98;
          end; // case (OSV.dwBuildNumber and $FFFF)
        90:
          case (OSV.dwBuildNumber and $FFFF) of
            2476:
              result:= OS_WINMEBETA;
            3000:
              result:= OS_WINME;
            else
              result:= OS_WINME;
          end; // case (OSV.dwBuildNumber and $FFFF)
      end; // case OSV.dwMinorVersion

   end // if OSV.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS
   else if OSV.dwPlatformId = VER_PLATFORM_WIN32_NT then begin
      case OSV.dwMajorVersion of
        3:
          case OSV.dwMinorVersion of
            1:
              result:= OS_NT31;
            5, 50:
              result:= OS_NT350;
            else
              result:= OS_NT351;
          end; // case OSV.dwMinorVersion
        4:
          case OSV.wProductType of
            VER_NT_DOMAIN_CONTROLLER:
              result:= OS_NT4_DOMAINCONTROLLER;
            VER_NT_SERVER:
              result:= OS_NT4_SERVER;
            VER_NT_WORKSTATION:
              result:= OS_NT4_WORKSTATION;
          end; // case OSV.wProductType
        5:
          case OSV.dwMinorVersion of
            0:
              if (OSV.wSuiteMask and VER_SUITE_ENTERPRISE) <> 0 then begin
                  result:= OS_WIN2000_ADVSERVER;
              end else if (OSV.wSuiteMask and VER_SUITE_DATACENTER) <> 0 then begin
                  result:= OS_WIN2000_DATACENTER;
              end else begin
                  result:= OS_WIN2000;
              end;
           1:
              if GetSystemMetrics(SM_MEDIACENTER) <> 0 then begin
                result:= OS_WINXP_MEDIACENTER;
              end else if GetSystemMetrics(SM_STARTER) <> 0 then begin
                result:= OS_WINXP_STARTER;
              end else if GetSystemMetrics(SM_TABLETPC) <> 0 then begin
                result:= OS_WINXP_TABLET;
              end else begin
                if OSV.wSuiteMask and VER_SUITE_PERSONAL > 0 then begin
                    result:= OS_WINXP_HOME;
                end else if OSV.wSuiteMask and VER_SUITE_ENTERPRISE > 0 then begin
                    result:= OS_DOTNETSERVER;
                end else if OSV.wSuiteMask and VER_SUITE_EMBEDDEDNT > 0 then begin
                    result:= OS_WINXP_EMBEDDED;
                end else begin
                  if SI.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_IA64 then begin
                    result:= OS_WINXP_IA64;
                  end else begin
                    result:= OS_WINXP_PROFESSIONAL;
                  end;
                end;
              end;
           2:
              if GetSystemMetrics(SM_SERVERr2) = 0 then begin
                if (OSV.wProductType = VER_NT_WORKSTATION) and
                   ((SI.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_AMD64) or dwWOW64IsRunning)
                then
                  result:= OS_WINXP_PROFESSIONAL_X64
                else // if OSV.wProductType = VER_NT_WORKSTATION

                if SI.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_IA64 then begin
                  if (OSV.wSuiteMask and VER_SUITE_DATACENTER) <> 0 then begin
                      result:= OS_WINDOWS_SERVER_2003_DATACENTER_ITANIUM;
                  end else if (OSV.wSuiteMask and VER_SUITE_ENTERPRISE) <> 0 then begin
                      result:= OS_WINDOWS_SERVER_2003_ENTERPRISE_ITANIUM;
                  end;
                end else if (SI.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_AMD64) or dwWOW64IsRunning then begin
                  if (OSV.wSuiteMask and VER_SUITE_DATACENTER) <> 0 then begin
                      result:= OS_WINDOWS_SERVER_2003_DATACENTER_X64;
                  end else if (OSV.wSuiteMask and VER_SUITE_COMPUTE_SERVER) <> 0 then begin
                      result:= OS_WINDOWS_SERVER_2003_COMPUTE_CLUSTER_X64;
                  end else if (OSV.wSuiteMask and VER_SUITE_ENTERPRISE) <> 0 then begin
                      result:= OS_WINDOWS_SERVER_2003_ENTERPRISE_X64;
                  end else if (OSV.wSuiteMask and VER_SUITE_SMALLBUSINESS <> 0) and
                              (OSV.wSuiteMask and VER_SUITE_SMALLBUSINESS_RESTRICTED <> 0) then begin
                      result:= OS_WINDOWS_SERVER_2003_SMALL_BUSINESS_X64;
                  end else if (OSV.wSuiteMask and VER_SUITE_STORAGE_SERVER) <> 0 then begin
                      result:= OS_WINDOWS_SERVER_2003_STORAGE_SERVER_X64;
                  end else if (OSV.wSuiteMask and VER_SUITE_WH_SERVER) <> 0 then begin
                      result:= OS_WINDOWS_HOME_SERVER_2003_X64;
                  end else begin
                      result:= OS_WINDOWS_SERVER_2003_X64;
                  end;
                end else begin
                  if (OSV.wSuiteMask and VER_SUITE_DATACENTER) <> 0 then begin
                      result:= OS_WINDOWS_SERVER_2003_DATACENTER;
                  end else if (OSV.wSuiteMask and VER_SUITE_COMPUTE_SERVER) <> 0 then begin
                      result:= OS_WINDOWS_SERVER_2003_COMPUTE_CLUSTER;
                  end else if (OSV.wSuiteMask and VER_SUITE_ENTERPRISE) <> 0 then begin
                      result:= OS_WINDOWS_SERVER_2003_ENTERPRISE;
                  end else if (OSV.wSuiteMask and VER_SUITE_SECURITY_APPLIANCE) <> 0 then begin
                      result:= OS_WINDOWS_SERVER_2003_SECAPPL;
                  end else if (OSV.wSuiteMask and VER_SUITE_SMALLBUSINESS <> 0) and
                              (OSV.wSuiteMask and VER_SUITE_SMALLBUSINESS_RESTRICTED <> 0) then begin
                      result:= OS_WINDOWS_SERVER_2003_SMALL_BUSINESS;
                  end else if (OSV.wSuiteMask and VER_SUITE_STORAGE_SERVER) <> 0 then begin
                      result:= OS_WINDOWS_SERVER_2003_STORAGE_SERVER;
                  end else if (OSV.wSuiteMask and VER_SUITE_BLADE) <> 0 then begin
                      result:= OS_WINDOWS_SERVER_2003_WEBEDITION;
                  end else if (OSV.wSuiteMask and VER_SUITE_WH_SERVER) <> 0 then begin
                      result:= OS_WINDOWS_HOME_SERVER_2003;
                  end else begin
                      result:= OS_WINDOWS_SERVER_2003;
                  end;
                end;
              end else begin // GetSystemMetrics(SM_SERVERr2) = 0
                if SI.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_IA64 then begin
                  if (OSV.wSuiteMask and VER_SUITE_DATACENTER) <> 0 then begin
                      result:= OS_WINDOWS_SERVER_2003_R2_DATACENTER_ITANIUM;
                  end else if (OSV.wSuiteMask and VER_SUITE_ENTERPRISE) <> 0 then begin
                      result:= OS_WINDOWS_SERVER_2003_R2_ENTERPRISE_ITANIUM;
                  end;
                end else if (SI.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_AMD64) or dwWOW64IsRunning then begin
                  if (OSV.wSuiteMask and VER_SUITE_DATACENTER) <> 0 then begin
                      result:= OS_WINDOWS_SERVER_2003_R2_DATACENTER_X64;
                  end else if (OSV.wSuiteMask and VER_SUITE_COMPUTE_SERVER) <> 0 then begin
                      result:= OS_WINDOWS_SERVER_2003_R2_COMPUTE_CLUSTER_X64;
                  end else if (OSV.wSuiteMask and VER_SUITE_ENTERPRISE) <> 0 then begin
                      result:= OS_WINDOWS_SERVER_2003_R2_ENTERPRISE_X64;
                  end else if (OSV.wSuiteMask and VER_SUITE_SMALLBUSINESS <> 0) and
                              (OSV.wSuiteMask and VER_SUITE_SMALLBUSINESS_RESTRICTED <> 0) then begin
                      result:= OS_WINDOWS_SERVER_2003_R2_SMALL_BUSINESS_X64;
                  end else if (OSV.wSuiteMask and VER_SUITE_STORAGE_SERVER) <> 0 then begin
                      result:= OS_WINDOWS_SERVER_2003_R2_STORAGE_SERVER_X64;
                  end else if (OSV.wSuiteMask and VER_SUITE_WH_SERVER) <> 0 then begin
                      result:= OS_WINDOWS_HOME_SERVER_2003_R2_X64;
                  end else begin
                      result:= OS_WINDOWS_SERVER_2003_R2_X64;
                  end;
                end else begin
                  if (OSV.wSuiteMask and VER_SUITE_DATACENTER) <> 0 then begin
                      result:= OS_WINDOWS_SERVER_2003_R2_DATACENTER;
                  end else if (OSV.wSuiteMask and VER_SUITE_COMPUTE_SERVER) <> 0 then begin
                      result:= OS_WINDOWS_SERVER_2003_R2_COMPUTE_CLUSTER;
                  end else if (OSV.wSuiteMask and VER_SUITE_ENTERPRISE) <> 0 then begin
                      result:= OS_WINDOWS_SERVER_2003_R2_ENTERPRISE;
                  end else if (OSV.wSuiteMask and VER_SUITE_SECURITY_APPLIANCE) <> 0 then begin
                      result:= OS_WINDOWS_SERVER_2003_R2_SECAPPL;
                  end else if (OSV.wSuiteMask and VER_SUITE_SMALLBUSINESS <> 0) and
                              (OSV.wSuiteMask and VER_SUITE_SMALLBUSINESS_RESTRICTED <> 0) then begin
                      result:= OS_WINDOWS_SERVER_2003_R2_SMALL_BUSINESS;
                  end else if (OSV.wSuiteMask and VER_SUITE_STORAGE_SERVER) <> 0 then begin
                      result:= OS_WINDOWS_SERVER_2003_R2_STORAGE_SERVER;
                  end else if (OSV.wSuiteMask and VER_SUITE_BLADE) <> 0 then begin
                      result:= OS_WINDOWS_SERVER_2003_R2_WEBEDITION;
                  end else if (OSV.wSuiteMask and VER_SUITE_WH_SERVER) <> 0 then begin
                      result:= OS_WINDOWS_HOME_SERVER_2003_R2;
                  end else begin
                      result:= OS_WINDOWS_SERVER_2003_R2;
                  end;
                end;
              end; // GetSystemMetrics(SM_SERVERr2) = 0
           end; // case OSV.dwMinorVersion
        6:
          case OSV.dwMinorVersion of
            0: // <-- Vista series
              case OSV.wProductType of
                VER_NT_WORKSTATION:
                  case dwiGetProductInfo(OSV) of
                    PRODUCT_UNKNOWN:
                      result:= OS_WINDOWS_VISTA;
                    PRODUCT_STARTER:
                      result:= OS_WINDOWS_VISTA_STARTER;
                    PRODUCT_HOME_BASIC:
                      result:= OS_WINDOWS_VISTA_HOME_BASIC;
                    PRODUCT_HOME_BASIC_N:
                      result:= OS_WINDOWS_VISTA_HOME_BASIC_N;
                    PRODUCT_HOME_PREMIUM:
                      result:= OS_WINDOWS_VISTA_HOME_PREMIUM;
                    PRODUCT_HOME_PREMIUM_N:
                      result:= OS_WINDOWS_VISTA_HOME_PREMIUM_N;
                    PRODUCT_BUSINESS:
                      result:= OS_WINDOWS_VISTA_BUSINESS;
                    PRODUCT_BUSINESS_N:
                      result:= OS_WINDOWS_VISTA_BUSINESS_N;
                    PRODUCT_ENTERPRISE:
                      result:= OS_WINDOWS_VISTA_ENTERPRISE;
                    PRODUCT_ENTERPRISE_N:
                      result:= OS_WINDOWS_VISTA_ENTERPRISE_N;
                    PRODUCT_ULTIMATE:
                      result:= OS_WINDOWS_VISTA_ULTIMATE;
                    PRODUCT_ULTIMATE_N:
                      result:= OS_WINDOWS_VISTA_ULTIMATE_N;
                  end; // case dwiGetProductInfo(OSV)
                else // case OSV.wProductType
                  case dwiGetProductInfo(OSV) of
                    PRODUCT_UNKNOWN:
                      result:= OS_WINDOWS_SERVER_2008;
                    PRODUCT_SERVER_FOUNDATION:
                      result:= OS_WINDOWS_SERVER_2008_FOUNDATION;
                    PRODUCT_STANDARD_SERVER:
                      result:= OS_WINDOWS_SERVER_2008_STANDARD;
                    PRODUCT_STANDARD_SERVER_CORE:
                      result:= OS_WINDOWS_SERVER_2008_STANDARD_CORE;
                    PRODUCT_STANDARD_SERVER_CORE_V:
                      result:= OS_WINDOWS_SERVER_2008_STANDARD_CORE_V;
                    PRODUCT_ENTERPRISE_SERVER:
                      result:= OS_WINDOWS_SERVER_2008_ENTERPRISE;
                    PRODUCT_ENTERPRISE_SERVER_V:
                      result:= OS_WINDOWS_SERVER_2008_ENTERPRISE_V;
                    PRODUCT_ENTERPRISE_SERVER_CORE:
                      result:= OS_WINDOWS_SERVER_2008_ENTERPRISE_CORE;
                    PRODUCT_ENTERPRISE_SERVER_CORE_V:
                      result:= OS_WINDOWS_SERVER_2008_ENTERPRISE_CORE_V;
                    PRODUCT_ENTERPRISE_SERVER_IA64:
                      result:= OS_WINDOWS_SERVER_2008_IA64;
                  end; // case dwiGetProductInfo(OSV)
              end; // case dwiGetProductInfo(OSV)
            1: // <-- Seven series
              case OSV.wProductType of
                VER_NT_WORKSTATION:
                  case dwiGetProductInfo(OSV) of
                    PRODUCT_STARTER:
                      if (SI.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_AMD64) or dwWOW64IsRunning then
                        result:= OS_WINDOWS_7_STARTER_X64
                      else
                        result:= OS_WINDOWS_7_STARTER;
                    PRODUCT_HOME_BASIC:
                      if (SI.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_AMD64) or dwWOW64IsRunning then
                        result:= OS_WINDOWS_7_HOME_BASIC_X64
                      else
                        result:= OS_WINDOWS_7_HOME_BASIC;
                    PRODUCT_HOME_BASIC_N:
                      if (SI.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_AMD64) or dwWOW64IsRunning then
                        result:= OS_WINDOWS_7_HOME_BASIC_N_X64
                      else
                        result:= OS_WINDOWS_7_HOME_BASIC_N;
                    PRODUCT_HOME_PREMIUM:
                      if (SI.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_AMD64) or dwWOW64IsRunning then
                        result:= OS_WINDOWS_7_HOME_PREMIUM_X64
                      else
                        result:= OS_WINDOWS_7_HOME_PREMIUM;
                    PRODUCT_HOME_PREMIUM_N:
                      if (SI.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_AMD64) or dwWOW64IsRunning then
                        result:= OS_WINDOWS_7_HOME_PREMIUM_N_X64
                      else
                        result:= OS_WINDOWS_7_HOME_PREMIUM_N;
                    PRODUCT_HOME_PREMIUM_SERVER:
                      if (SI.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_AMD64) or dwWOW64IsRunning then
                        result:= OS_WINDOWS_HOME_SERVER_2011_X64
                      else
                        result:= OS_WINDOWS_HOME_SERVER_2011;
                    PRODUCT_HOME_SERVER:
                      if (SI.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_AMD64) or dwWOW64IsRunning then
                        result:= OS_WINDOWS_STORAGE_SERVER_2008_R2_ESSENTIALS_X64
                      else
                        result:= OS_WINDOWS_STORAGE_SERVER_2008_R2_ESSENTIALS;
                    PRODUCT_PROFESSIONAL:
                      if (SI.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_AMD64) or dwWOW64IsRunning then
                        result:= OS_WINDOWS_7_PROFESSIONAL_X64
                      else
                        result:= OS_WINDOWS_7_PROFESSIONAL;
                    PRODUCT_PROFESSIONAL_N:
                      if (SI.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_AMD64) or dwWOW64IsRunning then
                        result:= OS_WINDOWS_7_PROFESSIONAL_N_X64
                      else
                        result:= OS_WINDOWS_7_PROFESSIONAL_N;
                    PRODUCT_ENTERPRISE:
                      if (SI.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_AMD64) or dwWOW64IsRunning then
                        result:= OS_WINDOWS_7_ENTERPRISE_X64
                      else
                        result:= OS_WINDOWS_7_ENTERPRISE;
                    PRODUCT_ENTERPRISE_N:
                      if (SI.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_AMD64) or dwWOW64IsRunning then
                        result:= OS_WINDOWS_7_ENTERPRISE_N_X64
                      else
                        result:= OS_WINDOWS_7_ENTERPRISE_N;
                    PRODUCT_ULTIMATE:
                      if (SI.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_AMD64) or dwWOW64IsRunning then
                        result:= OS_WINDOWS_7_ULTIMATE_X64
                      else
                        result:= OS_WINDOWS_7_ULTIMATE;
                    PRODUCT_ULTIMATE_N:
                      if (SI.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_AMD64) or dwWOW64IsRunning then
                        result:= OS_WINDOWS_7_ULTIMATE_N_X64
                      else
                        result:= OS_WINDOWS_7_ULTIMATE_N;
                  end; // case dwiGetProductInfo(OSV)
                else //case OSV.wProductType
                  case dwiGetProductInfo(OSV) of
                    PRODUCT_UNKNOWN:
                      result:= OS_WINDOWS_SERVER_2008_R2;
                    PRODUCT_SERVER_FOUNDATION:
                      result:= OS_WINDOWS_SERVER_2008_R2_FOUNDATION;
                    PRODUCT_STANDARD_SERVER:
                      result:= OS_WINDOWS_SERVER_2008_R2_STANDARD;
                    PRODUCT_STANDARD_SERVER_CORE:
                      result:= OS_WINDOWS_SERVER_2008_R2_STANDARD_CORE;
                    PRODUCT_STANDARD_SERVER_CORE_V:
                      result:= OS_WINDOWS_SERVER_2008_R2_STANDARD_CORE_V;
                    PRODUCT_ENTERPRISE_SERVER:
                      result:= OS_WINDOWS_SERVER_2008_R2_ENTERPRISE;
                    PRODUCT_ENTERPRISE_SERVER_V:
                      result:= OS_WINDOWS_SERVER_2008_R2_ENTERPRISE_V;
                    PRODUCT_ENTERPRISE_SERVER_CORE:
                      result:= OS_WINDOWS_SERVER_2008_R2_ENTERPRISE_CORE;
                    PRODUCT_ENTERPRISE_SERVER_CORE_V:
                      result:= OS_WINDOWS_SERVER_2008_R2_ENTERPRISE_CORE_V;
                    PRODUCT_ENTERPRISE_SERVER_IA64:
                      result:= OS_WINDOWS_SERVER_2008_R2_IA64;
                    PRODUCT_HOME_PREMIUM_SERVER:
                      result:= OS_WINDOWS_HOME_SERVER_2011;
                    PRODUCT_HOME_SERVER:
                      result:= OS_WINDOWS_STORAGE_SERVER_2008_R2_ESSENTIALS;
                  end; // case dwiGetProductInfo(OSV)
              end; // case OSV.wProductType
            2: // <-- Eight series
              begin
               // (When its time... )
              end;
          end; // case OSV.dwMinorVersion
      end; // case OSV.dwMajorVersion
   end; // else if OSV.dwPlatformId = VER_PLATFORM_WIN32_NT
end;
Man findet ja die komplette Aufstellung bis Win 95 zurück nicht mehr im MSDN. Ich habs auch nur über die Jahre immer mitgepflegt, heute nachträglich müsste man schon ganz schön suchen. Die N-Versionen werden ja auch größtenteils totgeschwiegen.
  Mit Zitat antworten Zitat