AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Win32/Win64 API (native code) Delphi Falscher Product Type in OSVersionInfoEx
Thema durchsuchen
Ansicht
Themen-Optionen

Falscher Product Type in OSVersionInfoEx

Ein Thema von Nersgatt · begonnen am 7. Dez 2012 · letzter Beitrag vom 24. Dez 2012
 
Benutzerbild von Nersgatt
Nersgatt

Registriert seit: 12. Sep 2008
Ort: Emlichheim
693 Beiträge
 
Delphi 10.1 Berlin Professional
 
#1

Falscher Product Type in OSVersionInfoEx

  Alt 7. Dez 2012, 08:47
Moin,

ich ermittle wie folgt die Windowsversion
Delphi-Quellcode:
function GetOSVersionInfoEx : TOSVersionInfoEx;
var
  OSVersionInfo : TOSVersionInfo absolute Result;
  Done : Boolean;
begin
  FillChar(Result, SizeOf(Result), #0);
  Done := False;
  try
    Result.dwOSVersionInfoSize := SizeOf(TOSVersionInfoEx);
    Done := GetOSVersionEx(Result);
  except
  end;
  if not(Done) then
  begin
    try
      FillChar(Result, SizeOf(Result), #0);
      Result.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);
      GetVersionEx(OSVersionInfo);
    except
    end;
  end;
end;

function GetWinVersion : string;
var
  OSInfo : TOSVersionInfoEx;
begin
  Result := 'Unbekannte Windows-Version';

  OSInfo := GetOSVersionInfoEx;

  case OSInfo.dwPlatformId of
    VER_PLATFORM_WIN32s:
      begin
        Result := 'Win32s';
      end;
    VER_PLATFORM_WIN32_WINDOWS:
      begin
        if (OSInfo.dwMajorVersion = 4) and (OSInfo.dwMinorVersion = 0) then
          Result := 'Windows 95';
        if (OSInfo.dwMajorVersion = 4) and (OSInfo.dwMinorVersion = 10) then
          Result := 'Windows 98';
        if (OSInfo.dwMajorVersion = 4) and (OSInfo.dwMinorVersion = 90) then
          Result := 'Windows Millennium Edition';
      end;
    VER_PLATFORM_WIN32_NT:
      begin
        if (OSInfo.dwMajorVersion = 4) and (OSInfo.dwMinorVersion = 0) then
          Result := 'Windows NT';
        if (OSInfo.dwMajorVersion = 5) and (OSInfo.dwMinorVersion = 0) then
          Result := 'Windows 2000';
        if (OSInfo.dwMajorVersion = 5) and (OSInfo.dwMinorVersion = 1) then
          Result := 'Windows XP';

        if (OSInfo.dwMajorVersion = 5) and (OSInfo.dwMinorVersion = 2) then
        begin
          if GetSystemMetrics(SM_SERVERR2) <> 0 then
            Result := 'Windows Server 2003 "R2"'
           else
             if (OSInfo.wProductType = VER_NT_WORKSTATION) then
               Result := 'Windows XP x64'
             else
               if OSInfo.wSuiteMask = VER_SUITE_WH_SERVER then
                 Result := 'Windows Home Server'
               else
                 Result := 'Windows Server 2003';
        end;

        if (OSInfo.dwMajorVersion = 6) and (OSInfo.dwMinorVersion = 0) then
        begin
          if (OSInfo.wProductType = VER_NT_WORKSTATION) then
            Result := 'Windows Vista'
          else
            Result := 'Windows Server 2008';
        end;

        if (OSInfo.dwMajorVersion = 6) and (OSInfo.dwMinorVersion = 1) then
        begin
          if (OSInfo.wProductType = VER_NT_WORKSTATION) then
            Result := 'Windows 7'
          else
            Result := 'Windows Server 2008 R2';
        end;

        if (OSInfo.dwMajorVersion = 6) and (OSInfo.dwMinorVersion = 2) then
        begin
          if (OSInfo.wProductType = VER_NT_WORKSTATION) then
            result := 'Windows 8'
          else
            result := 'Windows Server 2012';
        end;


        if (OSInfo.wSuiteMask and VER_SUITE_PERSONAL) = VER_SUITE_PERSONAL then
          Result := Result + ' Home Edition'
        else
          Result := Result + ' Professional';

      end;
  end;
  Result := Trim(Result + ' ' + OSInfo.szCSDVersion);
end;
Was ich nicht verstehe: mein Programm läuft auf einem Windows 7 in einer virtuellen Maschine. Nach der Zeile (OSInfo.dwMajorVersion = 6) and (OSInfo.dwMinorVersion = 1) hab ich in OSInfo.wProductType ein 0 stehen. Ich würde hier eine 1 (=VER_NT_WORKSTATION) erwarten. Was mache ich falsch?

Danke!
Jens
Jens
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 00:11 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz