Routine Issues to Identify Windows Version

Asked

Viewed 710 times

0

I’m having trouble in a routine that identifies the windows version. In case I’m using Delphi 7, I put the routine in a program that solves and puts in a textbox, beauty worked, I made some changes and perfect the answer checks with the windows operating system I am using 'WINSEVEN00PRO2610000000000' but when I copy the whole routine and put in the system I give maintenance the execution response is WINXP00000PRO2510000000000, different, how to explain and how to solve. Thank you for your cooperation:

const
  VER_NT_WORKSTATION    :Integer = 1;
  VER_SUITE_ENTERPRISE  :Integer = 2;
  VER_NT_SERVER         :Integer = 3;
  VER_SUITE_DATACENTER  :Integer = 128;
  VER_SUITE_PERSONAL    :Integer = 512;
  vSONAOIDENTIFICADO    :String = 'WINDOWS';
  vSOWIN9X              :String = 'WIN9X';
  vSOWIN2000            :String = 'WIN2K';
  vSOWINXP              :String = 'WINXP';
  vSOWINXPpro           :String = 'WINXPPRO';
  vSOWIN7               :String = 'WINSEVEN';
  vSOWIN8               :String = 'WINEIGHT';
  vSOVISTA              :String = 'WINVISTA';
  vULTIMATE             :String = 'ULT';
  vHOMEPREMIUM          :String = 'HPR';
  vHOMEBASIC            :String = 'HBS';
  vPROFESSIONAL         :String = 'PRO';
  vSTANDARD             :String = 'STD';

function TForm1.GetSO: string;
    function CompletarZeros(sString: string; iTamanho: Integer): String;
    begin
        Result := sString;
        while Length(Result) < iTamanho do
            Result := Result+'0';
    end;
var
    NTBres, BRes: Boolean;
    verInfo: TOSVersionInfo;
    verInfo_NT: TOSVersionInfoW;
    i: word;
    str, ProductName, ProductNameEx, VersionL : string;
    pdwReturnedProductType : DWORD;
begin
    Result := 'Error';
    NTBres := False;
    try
        verInfo_NT.dwOSVersionInfoSize := SizeOf(TOSVERSIONINFOEX);
        NTBRes := GetVersionEx(verInfo);
        verInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);
        BRes := GetVersionEx(verInfo);
    except
        verInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);
        BRes := GetVersionEx(verInfo);
    end;
    if (not BRes) and (not NTBres) then
        Exit;
    Move( verInfo, verInfo_NT, SizeOf(TOSVersionInfo) );

    verInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);
    if GetVersionEx(verInfo) then
        VersionL := IntToStr(verInfo.dwPlatformId)+IntToStr(verInfo.dwMajorVersion) + IntToStr(verInfo.dwMinorVersion);

    case verInfo.dwPlatformId of
        VER_PLATFORM_WIN32s : ProductName := vSOWIN9X;
        VER_PLATFORM_WIN32_WINDOWS : ProductName := vSOWIN9X;
        VER_PLATFORM_WIN32_NT:
            begin
                case verInfo.dwMajorVersion  of
                    0..4: ProductName := vSONAOIDENTIFICADO;
                    5:  begin
                            case verInfo.dwMinorVersion of
                                0: ProductName := vSOWIN2000;//;//'Windows 2000';
                                1: ProductName := vSOWINXP;//'Windows XP';
                                2: productName := vSOWINXPpro;//'Windows XP Prof';
                            else
                                Result := IntToStr(verInfo.dwMajorVersion)+IntToStr(verInfo.dwMinorVersion)+ vSONAOIDENTIFICADO;
                            end;
                        end;
                    6:  begin
                            case verInfo.dwMinorVersion of
                                0:ProductName := vSOVISTA ;//'Windows Vista';
                                1:ProductName := vSOWIN7;//'Windows 7';
                                2:ProductName := vSOWIN8;//'Windows 8';
                            else
                                ProductName := IntToStr(verInfo.dwMajorVersion)+IntToStr(verInfo.dwMinorVersion)+ vSONAOIDENTIFICADO;
                            end;
                        end;
                else
                    ProductName := IntToStr(verInfo.dwMajorVersion)+IntToStr(verInfo.dwMinorVersion)+vSONAOIDENTIFICADO;
                end;
            end;
    ELSE
        ProductName := IntToStr(verInfo.dwMajorVersion)+IntToStr(verInfo.dwMinorVersion)+vSONAOIDENTIFICADO
    end;
    str := '';
    ProductNameEx :=IntToStr(verInfo.dwMajorVersion)+IntToStr(verInfo.dwMinorVersion)+vSONAOIDENTIFICADO+IntToStr(-1);
    if Assigned ( GetProductInfo) then
    begin
        ProductNameEx :='';
        GetProductInfo(verInfo.dwMajorVersion, verInfo.dwMinorVersion, 0,0, pdwReturnedProductType);
        case pdwReturnedProductType of
          0:    begin
                    if (verInfo.dwMajorVersion = 5) and (verInfo.dwMinorVersion=1) then
                        ProductNameEx := vPROFESSIONAL //'Professional'
                    else
                        ProductNameEx := vSTANDARD;//'Standard';
                end;
          1: ProductNameEx:=  vULTIMATE;
          2: ProductNameEx:=  vHOMEBASIC;
          3: ProductNameEx:=  vHOMEPREMIUM;//'Home Premium';
          5: ProductNameEx:=  vHOMEBASIC;// 'Home Basic'  ;
          28: ProductNameEx:= vULTIMATE;//  'Ultimate';
          48,49: ProductNameEx:= vPROFESSIONAL;// 'Professional' ;
          68: ProductNameEx:= vHOMEPREMIUM;// 'Home Premium';
          69: ProductNameEx:= vPROFESSIONAL;// 'Professional';
          71: ProductNameEx:= vULTIMATE;// 'Ultimate';
        else ;
            ProductNameEx :=IntToStr(verInfo.dwMajorVersion)+IntToStr(verInfo.dwMinorVersion)+vSONAOIDENTIFICADO+IntToStr(pdwReturnedProductType);
        end;
    end;
    for I := 0 to 127 do
        str := str + verInfo.szCSDVersion[i];
//    STR := StringReplace(UpperCase(str), 's', 'S', [rfReplaceAll]);
//    STR := StringReplace(UpperCase(str), 'p', 'P', [rfReplaceAll]);
    STR := StringReplace(UpperCase(str), ' ', '', [rfReplaceAll]);
    STR := Trim(str);
    if Length(Version) < 4 then
        VersionL := CompletarZeros(VersionL, 4);
    if Length(str) < 3 then
        str := CompletarZeros(str, 3);
    str := str+' >'+IntToStr(pdwReturnedProductType);
    Result := CompletarZeros(ProductName,10)+CompletarZeros(ProductNameEx+VersionL,16); //+ Version + str;
end;
  • What is the version of the other S.O?

  • WINDOWS 7 PROFESSIONAL 32

1 answer

1


A while ago I found in Google a library (Unit) specific to this, which is one of the most complete I have seen to date. I’m sending you down. Copy and save to a file with the name Getwinversioninfo.pas, inside the folder of your project, then just add "Getwinversioninfo" in the "Uses" clause. I hope I’ve helped!

unit GetWinVersionInfo;

interface

uses
  Windows,
  Registry,
  SysUtils;

function GetOSInfo: string;

implementation

type
  _OSVERSIONINFOEX = record
    dwOSVersionInfoSize : DWORD;
    dwMajorVersion      : DWORD;
    dwMinorVersion      : DWORD;
    dwBuildNumber       : DWORD;
    dwPlatformId        : DWORD;
    szCSDVersion        : array[0..127] of AnsiChar;
    wServicePackMajor   : WORD;
    wServicePackMinor   : WORD;
    wSuiteMask          : WORD;
    wProductType        : BYTE;
    wReserved           : BYTE;
  end;
  TOSVERSIONINFOEX = _OSVERSIONINFOEX;

  function GetVersionExA(var lpVersionInformation: TOSVersionInfoEX): BOOL;
        stdcall; external kernel32;

const
  VER_NT_WORKSTATION    :Integer = 1;
  VER_SUITE_ENTERPRISE  :Integer = 2;
  VER_NT_SERVER         :Integer = 3;
  VER_SUITE_DATACENTER  :Integer = 128;
  VER_SUITE_PERSONAL    :Integer = 512;

const
  PRODUCT_BUSINESS                      = $00000006; {Business Edition}
  PRODUCT_BUSINESS_N                    = $00000010; {Business Edition}

  PRODUCT_CLUSTER_SERVER                = $00000012; {HPC Edition}
  PRODUCT_CLUSTER_SERVER_V              = $00000040; {Server Hyper Core V Edition}

  PRODUCT_CORE                          = $00000065; {Windows 8}
  PRODUCT_CORE_N                        = $00000062; {Windows 8 N}
  PRODUCT_CORE_COUNTRYSPECIFIC          = $00000063; {Windows 8 China}
  PRODUCT_CORE_SINGLELANGUAGE           = $00000064; {Windows 8 Single Language}

  PRODUCT_DATACENTER_EVALUATION_SERVER  = $00000050; {Server Datacenter (evaluation installation)}
  PRODUCT_DATACENTER_SERVER             = $00000008; {Server Datacenter Edition (full installation)}
  PRODUCT_DATACENTER_SERVER_CORE        = $0000000C; {Server Datacenter Edition (core installation)}
  PRODUCT_DATACENTER_SERVER_CORE_V      = $00000027; {Server Datacenter without Hyper-V (core installation)}
  PRODUCT_DATACENTER_SERVER_V           = $00000025; {Server Datacenter without Hyper-V (full installation)}

  PRODUCT_ENTERPRISE                    = $00000004; {Enterprise Edition}
  PRODUCT_ENTERPRISE_E                  = $00000046; {Not supported}
  PRODUCT_ENTERPRISE_N_EVALUATION       = $00000054; {Enterprise N (evaluation installation)}
  PRODUCT_ENTERPRISE_N                  = $0000001B; {Enterprise N Edition}
  PRODUCT_ENTERPRISE_EVALUATION         = $00000048; {Server Enterprise (evaluation installation)}
  PRODUCT_ENTERPRISE_SERVER             = $0000000A; {Server Enterprise Edition (full installation)}
  PRODUCT_ENTERPRISE_SERVER_CORE        = $0000000E; {Server Enterprise Edition (core installation)}
  PRODUCT_ENTERPRISE_SERVER_CORE_V      = $00000029; {Server Enterprise without Hyper-V (core installation)}
  PRODUCT_ENTERPRISE_SERVER_IA64        = $0000000F; {Server Enterprise Edition for Itanium-based Systems}
  PRODUCT_ENTERPRISE_SERVER_V           = $00000026; {Server Enterprise without Hyper-V (full installation)}

  PRODUCT_ESSENTIALBUSINESS_SERVER_MGMT = $0000003B; {Windows Essential Server Solution Management}
  PRODUCT_ESSENTIALBUSINESS_SERVER_ADDL = $0000003C; {Windows Essential Server Solution Additional}
  PRODUCT_ESSENTIALBUSINESS_SERVER_MGMTSVC = $0000003D; {Windows Essential Server Solution Management SVC}
  PRODUCT_ESSENTIALBUSINESS_SERVER_ADDLSVC = $0000003E; {Windows Essential Server Solution Additional SVC}

  PRODUCT_HOME_BASIC                    = $00000002; {Home Basic Edition}
  PRODUCT_HOME_BASIC_E                  = $00000043; {Not supported}
  PRODUCT_HOME_BASIC_N                  = $00000005; {Home Basic Edition}
  PRODUCT_HOME_PREMIUM                  = $00000003; {Home Premium Edition}
  PRODUCT_HOME_PREMIUM_E                = $00000044; {Not supported}
  PRODUCT_HOME_PREMIUM_N                = $0000001A; {Home Premium Edition}
  PRODUCT_HOME_PREMIUM_SERVER           = $00000022; {Windows Home Premium Server 2011}
  PRODUCT_HOME_SERVER                   = $00000013; {Windows Home Server 2011}

  PRODUCT_HYPERV                        = $0000002A; {Microsoft Hyper-V Server}

  PRODUCT_MEDIUMBUSINESS_SERVER_MANAGEMENT = $0000001E; {Windows Essential Business Server Management Server}
  PRODUCT_MEDIUMBUSINESS_SERVER_MESSAGING = $00000020; {Windows Essential Business Server Messaging Server}
  PRODUCT_MEDIUMBUSINESS_SERVER_SECURITY = $0000001F; {Windows Essential Business Server Security Server}

  PRODUCT_MULTIPOINT_STANDARD_SERVER    = $0000004C; {Windows MultiPoint Server Standard (full installation)}
  PRODUCT_MULTIPOINT_PREMIUM_SERVER     = $0000004D; {Windows MultiPoint Server Premium (full installation)}

  PRODUCT_PROFESSIONAL                  = $00000030; {Professional}
  PRODUCT_PROFESSIONAL_E                = $00000045; {Not supported}
  PRODUCT_PROFESSIONAL_N                = $00000031; {Professional N}
  PRODUCT_PROFESSIONAL_WMC              = $00000067; {Professional with Media Center}

  PRODUCT_SB_SOLUTION_SERVER_EM         = $00000036; {Server For SB Solutions EM}
  PRODUCT_SERVER_FOR_SB_SOLUTIONS       = $00000033; {Server For SB Solutions}
  PRODUCT_SERVER_FOR_SB_SOLUTIONS_EM    = $00000037; {Server For SB Solutions EM}


  PRODUCT_SERVER_FOR_SMALLBUSINESS      = $00000018; {Windows Server 2008 for Windows Essential Server Solutions}
  PRODUCT_SERVER_FOR_SMALLBUSINESS_V    = $00000023; {Windows Server 2008 without Hyper-V for Windows Essential Server Solutions}

  PRODUCT_SERVER_FOUNDATION             = $00000021; {Server Foundation}
  PRODUCT_SB_SOLUTION_SERVER            = $00000032; {Windows Small Business Server 2011 Essentials}


  PRODUCT_SMALLBUSINESS_SERVER          = $00000009; {Small Business Server}
  PRODUCT_SMALLBUSINESS_SERVER_PREMIUM  = $00000019; {Small Business Server Premium Edition}
  PRODUCT_SMALLBUSINESS_SERVER_PREMIUM_CORE = $0000003F; {Small Business Server Premium (core installation)}

  PRODUCT_SOLUTION_EMBEDDEDSERVER       = $00000038; {Windows MultiPoint Server}

  PRODUCT_STANDARD_EVALUATION_SERVER    = $0000004F; {Server Standard (evaluation installation)}
  PRODUCT_STANDARD_SERVER               = $00000007; {Server Standard Edition (full installation)}
  PRODUCT_STANDARD_SERVER_CORE          = $0000000D; {Server Standard Edition (core installation)}
  PRODUCT_STANDARD_SERVER_V             = $00000024; {Server Standard without Hyper-V}
  PRODUCT_STANDARD_SERVER_CORE_V        = $00000028; {Server Standard without Hyper-V (core installation)}
  PRODUCT_STANDARD_SERVER_SOLUTIONS     = $00000034; {Server Solutions Premium}
  PRODUCT_STANDARD_SERVER_SOLUTIONS_CORE = $00000035; {Server Solutions Premium (core installation)}

  PRODUCT_STARTER                       = $0000000B; {Starter Edition}
  PRODUCT_STARTER_E                     = $00000042; {Not supported}
  PRODUCT_STARTER_N                     = $0000002F; {Starter N Edition}

  PRODUCT_STORAGE_ENTERPRISE_SERVER     = $00000017; {Storage Server Enterprise Edition}
  PRODUCT_STORAGE_ENTERPRISE_SERVER_CORE = $0000002E; {Storage Server Enterprise (core installation)}
  PRODUCT_STORAGE_EXPRESS_SERVER        = $00000014; {Storage Server Express Edition}
  PRODUCT_STORAGE_EXPRESS_SERVER_CORE   = $0000002B; {Storage Server Express (core installation)}
  PRODUCT_STORAGE_STANDARD_EVALUATION_SERVER = $00000060; {Storage Server Standard (evaluation installation)}
  PRODUCT_STORAGE_STANDARD_SERVER       = $00000015; {Storage Server Standard Edition}
  PRODUCT_STORAGE_STANDARD_SERVER_CORE  = $0000002C; {Storage Server Standard (core installation)}
  PRODUCT_STORAGE_WORKGROUP_EVALUATION_SERVER = $0000005F; {Storage Server Workgroup (evaluation installation)}
  PRODUCT_STORAGE_WORKGROUP_SERVER      = $00000016; {Storage Server Workgroup Edition}
  PRODUCT_STORAGE_WORKGROUP_SERVER_CORE = $0000002D; {Storage Server Workgroup (core installation)}

  PRODUCT_UNDEFINED                     = $00000000; {An unknown product}

  PRODUCT_ULTIMATE                      = $00000001; {Ultimate Edition}
  PRODUCT_ULTIMATE_N                    = $0000001C; {Ultimate Edition}

  PRODUCT_WEB_SERVER                    = $00000011; {Web Server Edition}
  PRODUCT_WEB_SERVER_CORE               = $0000001D; {Web Server (core installation)}
  PRODUCT_UNLICENSED                    = $ABCDABCD; {Unlicensed product}

var
  GetProductInfo: function (dwOSMajorVersion, dwOSMinorVersion,
                            dwSpMajorVersion, dwSpMinorVersion: DWORD;
                            var pdwReturnedProductType: DWORD): BOOL stdcall = NIL;

function GetOSInfo: string;
var
  NTBres, BRes: Boolean;
  OSVI: TOSVERSIONINFO;
  OSVI_NT: TOSVERSIONINFOEX;
  tmpStr: string;
  dwOSMajorVersion, dwOSMinorVersion,
  dwSpMajorVersion, dwSpMinorVersion,
  pdwReturnedProductType : DWORD;
begin
  Result := 'Error';
  NTBRes := FALSE;
  try
    OSVI_NT.dwOSVersionInfoSize := SizeOf(TOSVERSIONINFOEX);
    NTBRes := GetVersionExA(OSVI_NT);
    OSVI.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);
    BRes := GetVersionEx(OSVI);
  except
    OSVI.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);
    BRes := GetVersionEx(OSVI);
  end;
  if (not BRes) and (not NTBres) then
    Exit;
  Move( OSVI, OSVI_NT, SizeOf(TOSVersionInfo) );

  case OSVI_NT.dwPlatformId of
     VER_PLATFORM_WIN32_NT:
       begin
         if OSVI_NT.dwMajorVersion <= 4 then
           Result := 'Windows NT ';
         if (OSVI_NT.dwMajorVersion = 5) and (OSVI_NT.dwMinorVersion = 0) then
           Result := 'Windows 2000 ';
         if  (OSVI_NT.dwMajorVersion = 5) and (OSVI_NT.dwMinorVersion = 1) then
           Result := 'Windows XP ';
         if (OSVI_NT.dwMajorVersion = 6) {and (OSVI_NT.dwMinorVersion = 0)} then
         begin
           if (OSVI_NT.dwMinorVersion = 0) then
           begin
               if (OSVI_NT.wProductType = VER_NT_WORKSTATION) then
                   Result := 'Windows Vista '
               else
                   Result := 'Windows Server 2008 ';

           end;

           if (OSVI_NT.dwMinorVersion = 1) then
           begin
               if (OSVI_NT.wProductType = VER_NT_WORKSTATION) then
                   Result := 'Windows 7 '
               else
                   Result := 'Windows Server 2008 R2 ';

           end;

           if (OSVI_NT.dwMinorVersion = 2) then
           begin
               if (OSVI_NT.wProductType = VER_NT_WORKSTATION) then
                   Result := 'Windows 8 '
               else
                   Result := 'Windows Server 2012 ';

           end;

           if Assigned(GetProductInfo) then
           begin
             GetProductInfo( dwOSMajorVersion, dwOSMinorVersion,
                             dwSpMajorVersion, dwSpMinorVersion,
                             pdwReturnedProductType );
             case pdwReturnedProductType of
               PRODUCT_BUSINESS://
                 tmpStr := 'Business Edition';
               PRODUCT_BUSINESS_N:
                 tmpStr := 'Business Edition';

               PRODUCT_CLUSTER_SERVER://
                 tmpStr := 'Cluster Server Edition';
               PRODUCT_CLUSTER_SERVER_V://
                 tmpStr := 'Server hyper Core V Edition';

               PRODUCT_CORE://
                 tmpStr := 'Windows 8';
               PRODUCT_CORE_N://
                 tmpStr := 'Windows 8 N';
               PRODUCT_CORE_COUNTRYSPECIFIC://
                 tmpStr := 'Windows 8 China';
               PRODUCT_CORE_SINGLELANGUAGE://
                 tmpStr := 'Windows 8 Single Language';

               PRODUCT_DATACENTER_EVALUATION_SERVER://
                 tmpStr := 'Server Datacenter Edition (Evaluation installation)';
               PRODUCT_DATACENTER_SERVER://
                 tmpStr := 'Server Datacenter Edition (full installation)';
               PRODUCT_DATACENTER_SERVER_CORE://
                 tmpStr := 'Server Datacenter Edition (core installation)';
               PRODUCT_DATACENTER_SERVER_CORE_V://
                 tmpStr := 'Server Datacenter without Hyper-V (core installation)';
               PRODUCT_DATACENTER_SERVER_V://
                 tmpStr := 'Server Datacenter without Hyper-V (full installation)';


               PRODUCT_ENTERPRISE://
                 tmpStr := 'Enterprise Edition';
               PRODUCT_ENTERPRISE_E://
                 tmpStr := 'Not supported';
               PRODUCT_ENTERPRISE_N_EVALUATION:
                 tmpStr := 'Enterprise N (evaluation installation) Edition';
               PRODUCT_ENTERPRISE_N:
                 tmpStr := 'Enterprise N Edition';
               PRODUCT_ENTERPRISE_EVALUATION:
                 tmpStr := 'Enterprise (evaluation installation) Edition';
               PRODUCT_ENTERPRISE_SERVER://
                 tmpStr := 'Server Enterprise Edition (full installation)';
               PRODUCT_ENTERPRISE_SERVER_CORE://
                 tmpStr := 'Server Enterprise Edition (core installation)';
               PRODUCT_ENTERPRISE_SERVER_CORE_V://
                 tmpStr := 'Server Enterprise without Hyper-V Edition (core installation)';
               PRODUCT_ENTERPRISE_SERVER_IA64://
                 tmpStr := 'Server Enterprise Edition for Itanium-based Systems';
               PRODUCT_ENTERPRISE_SERVER_V://
                 tmpStr := 'Server Enterprise without Hyper-V Edition (full installation)';


               PRODUCT_ESSENTIALBUSINESS_SERVER_MGMT://
                 tmpStr := 'Windows Essential Server Solution Management';
               PRODUCT_ESSENTIALBUSINESS_SERVER_ADDL://
                 tmpStr := 'Windows Essential Server Solution Additional';
               PRODUCT_ESSENTIALBUSINESS_SERVER_MGMTSVC://
                 tmpStr := 'Windows Essential Server Solution Management SVC';
               PRODUCT_ESSENTIALBUSINESS_SERVER_ADDLSVC://
                 tmpStr := 'Windows Essential Server Solution Additional SVC';


               PRODUCT_HOME_BASIC://
                 tmpStr := 'Home Basic Edition';
               PRODUCT_HOME_BASIC_E://
                 tmpStr := 'Not supported';
               PRODUCT_HOME_BASIC_N:
                 tmpStr := 'Home Basic N Edition';
               PRODUCT_HOME_PREMIUM://
                 tmpStr := 'Home Premium Edition';
               PRODUCT_HOME_PREMIUM_E://
                 tmpStr := 'Not supported';
               PRODUCT_HOME_PREMIUM_N:
                 tmpStr := 'Home Premium N Edition';
               PRODUCT_HOME_PREMIUM_SERVER:
                 tmpStr := 'Home Premium Server Edition';
               PRODUCT_HOME_SERVER:
                 tmpStr := 'Home Server Edition';

               PRODUCT_HYPERV:
                 tmpStr := 'Microsoft Hyper-V Server Edition';

               PRODUCT_MEDIUMBUSINESS_SERVER_MANAGEMENT:
                 tmpStr := 'Windows Essential Business Server Management Edition';
               PRODUCT_MEDIUMBUSINESS_SERVER_MESSAGING:
                 tmpStr := 'Windows Essential Business Server Messaging Edition';
               PRODUCT_MEDIUMBUSINESS_SERVER_SECURITY:
                 tmpStr := 'Windows Essential Business Server Security Edition';

               PRODUCT_MULTIPOINT_STANDARD_SERVER:
                 tmpStr := 'Windows Multipoint Server Standard (full installation) Edition';
               PRODUCT_MULTIPOINT_PREMIUM_SERVER:
                 tmpStr := 'Windows Multipoint Server Premium (full installation) Edition';


               PRODUCT_PROFESSIONAL://
                 tmpStr := 'Professional Edition';
               PRODUCT_PROFESSIONAL_E://
                 tmpStr := 'Not Supported';
               PRODUCT_PROFESSIONAL_N://
                 tmpStr := 'Professional N Edition';
               PRODUCT_PROFESSIONAL_WMC://
                 tmpStr := 'Professional with Media Center Edition';

               PRODUCT_SB_SOLUTION_SERVER_EM://
                 tmpStr := 'Server For SB Solutions EM Edition';
               PRODUCT_SERVER_FOR_SB_SOLUTIONS://
                 tmpStr := 'Server For SB Solutions Edition';
               PRODUCT_SERVER_FOR_SB_SOLUTIONS_EM://
                 tmpStr := 'Server For SB Solutions EM Edition';



               PRODUCT_SERVER_FOR_SMALLBUSINESS:
                 tmpStr := 'Windows Server 2008 for Small Business Edition';
               PRODUCT_SERVER_FOR_SMALLBUSINESS_V:
                 tmpStr := 'Windows Server 2008 without Hyper-V for Small Business Edition';

               PRODUCT_SERVER_FOUNDATION:
                 tmpStr := 'Windows Server Foundation Edition';
               PRODUCT_SB_SOLUTION_SERVER://
                 tmpStr := 'Windows Small Business Server 2011 Essentials Edition';


               PRODUCT_SMALLBUSINESS_SERVER://
                 tmpStr := 'Small Business Server';
               PRODUCT_SMALLBUSINESS_SERVER_PREMIUM://
                 tmpStr := 'Small Business Server Premium Edition';
               PRODUCT_SMALLBUSINESS_SERVER_PREMIUM_CORE://
                 tmpStr := 'Small Business Server Premium (Core installation) Edition';

               PRODUCT_SOLUTION_EMBEDDEDSERVER://
                 tmpStr := 'Windows Multipoint Server';


               PRODUCT_STANDARD_EVALUATION_SERVER://
                 tmpStr := 'Server Standard Edition (evaluation installation)';
               PRODUCT_STANDARD_SERVER://
                 tmpStr := 'Server Standard Edition (full installation)';
               PRODUCT_STANDARD_SERVER_CORE://
                 tmpStr := 'Server Standard Edition (core installation)';
               PRODUCT_STANDARD_SERVER_V://
                 tmpStr := 'Server Standard without Hyper-V Edition';
               PRODUCT_STANDARD_SERVER_CORE_V://
                 tmpStr := 'Server Standard without Hyper-V Edition (core installation)';
               PRODUCT_STANDARD_SERVER_SOLUTIONS://
                 tmpStr := 'Server Solutions Premium';
               PRODUCT_STANDARD_SERVER_SOLUTIONS_CORE://
                 tmpStr := 'Server Solutions Premium (core installation)';




               PRODUCT_STARTER://
                 tmpStr := 'Starter Edition';
               PRODUCT_STARTER_E://
                 tmpStr := 'Not supported';
               PRODUCT_STARTER_N://
                 tmpStr := 'Starter N Edition';

               PRODUCT_STORAGE_ENTERPRISE_SERVER:
                 tmpStr := 'Storage Server Enterprise Edition';
               PRODUCT_STORAGE_ENTERPRISE_SERVER_CORE:
                 tmpStr := 'Storage Server Enterprise Edition (core installation)';
               PRODUCT_STORAGE_EXPRESS_SERVER:
                 tmpStr := 'Storage Server Express Edition';
               PRODUCT_STORAGE_EXPRESS_SERVER_CORE:
                 tmpStr := 'Storage Server Express Edition (core installation)';
               PRODUCT_STORAGE_STANDARD_EVALUATION_SERVER:
                 tmpStr := 'Storage Server Standard Edition (evaluation installation)';
               PRODUCT_STORAGE_STANDARD_SERVER:
                 tmpStr := 'Storage Server Standard Edition';
               PRODUCT_STORAGE_STANDARD_SERVER_CORE:
                 tmpStr := 'Storage Server Standard Edition (core installation)';
               PRODUCT_STORAGE_WORKGROUP_EVALUATION_SERVER:
                 tmpStr := 'Storage Server Workgroup Edition (evaluation installation)';
               PRODUCT_STORAGE_WORKGROUP_SERVER:
                 tmpStr := 'Storage Server Workgroup Edition';
               PRODUCT_STORAGE_WORKGROUP_SERVER_CORE:
                 tmpStr := 'Storage Server Workgroup Edition (core installation)';


               PRODUCT_UNDEFINED:
                 tmpStr := 'An unknown product';

               PRODUCT_ULTIMATE://
                 tmpStr := 'Ultimate Edition';
               PRODUCT_ULTIMATE_N:
                 tmpStr := 'Ultimate N Edition';

               PRODUCT_WEB_SERVER://
                 tmpStr := 'Web Server Edition';
               PRODUCT_WEB_SERVER_CORE://
                 tmpStr := 'Web Server Edition (core installation)';

               PRODUCT_UNLICENSED:
                 tmpStr := 'Unlicensed product';


             else
               tmpStr := '';
             end;{ pdwReturnedProductType }
             Result := Result + tmpStr;
             NTBRes := FALSE;
           end;{ GetProductInfo<>NIL }
         end;{ Vista }
         if NTBres then
         begin
           if OSVI_NT.wProductType = VER_NT_WORKSTATION then
           begin
             if OSVI_NT.wProductType = VER_NT_WORKSTATION then
             begin
               case OSVI_NT.wSuiteMask of
                 512: Result := Result + 'Personal';
                 768: Result := Result + 'Home Premium';
               else
                 Result := Result + 'Professional';
               end;
             end
             else if OSVI_NT.wProductType = VER_NT_SERVER then
             begin
               if OSVI_NT.wSuiteMask = VER_SUITE_DATACENTER then
                 Result := Result + 'DataCenter Server'
               else if OSVI_NT.wSuiteMask = VER_SUITE_ENTERPRISE then
                 Result :=  Result + 'Advanced Server'
               else
                 Result := Result + 'Server';
             end;
           end{ wProductType=VER_NT_WORKSTATION }
           else
           begin
             with TRegistry.Create do
               try
                 RootKey := HKEY_LOCAL_MACHINE;
                 if OpenKey{ReadOnly}('SYSTEM\CurrentControlSet\Control\ProductOptions', false) then
                   try
                     tmpStr := UpperCase(ReadString('ProductType'));
                     if tmpStr = 'WINNT' then
                       Result := Result + 'Workstation';
                     if tmpStr = 'SERVERNT' then
                       Result := Result + 'Server';
                   finally
                     CloseKey;
                   end;
               finally
                 Free;
               end;
             end;{ wProductType<>VER_NT_WORKSTATION }
           end;{ NTBRes }
         end;{ VER_PLATFORM_WIN32_NT }
     VER_PLATFORM_WIN32_WINDOWS:
       begin
         if (OSVI.dwMajorVersion = 4) and (OSVI.dwMinorVersion = 0) then
         begin
           Result := 'Windows 95 ';
           if OSVI.szCSDVersion[1] = 'C' then
             Result := Result + 'OSR2';
         end;
         if (OSVI.dwMajorVersion = 4) and (OSVI.dwMinorVersion = 10) then
         begin
           Result := 'Windows 98 ';
           if OSVI.szCSDVersion[1] = 'A' then
             Result := Result + 'SE';
         end;
         if (OSVI.dwMajorVersion = 4) and (OSVI.dwMinorVersion = 90) then
           Result := 'Windows Me';
       end;{ VER_PLATFORM_WIN32_WINDOWS }
     VER_PLATFORM_WIN32s:
       Result := 'Microsoft Win32s';
  else
    Result := 'Unknown';
  end;{ OSVI_NT.dwPlatformId }
end;{ GetOSInfo }

initialization
   @GetProductInfo := GetProcAddress(GetModuleHandle('KERNEL32.DLL'),
                                     'GetProductInfo');

end.
  • Hi, Paruba, hello, Paruba! Thanks, this function is however, what happens is that the program is marked as compatibility, so the response of the function does not correspond to the OS but rather the compatibility.

  • 1

    Please arrange the typos and explain better. I honestly didn’t understand anything...

  • Sorry. It’s the rush. The function you passed was the same one I put in the beginning. What happens for the program to answer the different OS in the program where I use the function, is because I mark the compatibility in the program. Knowing this, if my operating system is Windows 7 32 bit and the program is marked compatibility with Windows XP , the function will return the 'Windows XP' using this function. Anyway thanks. LMV Hugs

  • 1

    In that case you can try to get the Windows version by command prompt. Please see this link http://www.windows-commandline.com/find-windows-os-version-from-command/ and also https://pablosoares.wordpress.com/2011/09/28/workingcom-command/

Browser other questions tagged

You are not signed in. Login or sign up in order to post.