AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Windows Version ermitteln

Ein Thema von MagicAndre1981 · begonnen am 5. Feb 2005 · letzter Beitrag vom 23. Feb 2009
Antwort Antwort
Seite 1 von 3  1 23      
Benutzerbild von MagicAndre1981
MagicAndre1981

Registriert seit: 4. Jun 2004
Ort: Nordhausen
2.214 Beiträge
 
Delphi 7 Enterprise
 
#1

Windows Version ermitteln

  Alt 5. Feb 2005, 23:56
Hi,

in der Code-Library gibt es eine Funktion um die Windows-Version zu ermitteln. Ich habe nun Windows XP Media Center Edition 2005 bei meinem Notebook dabei gehabt, aber die Funktion aus der Code-Library sagt mir nun es ist WinXP Prof.
EVEREST Home Edition erkennt aber mein Windows als MCE.

Nun meine frage:
Wie kann man zw. WinXP Prof und WinXP MCE unterscheiden?

Mfg
André
Miniaturansicht angehängter Grafiken
windowsxpsp2prof_304.png   windowsxpmce_167.png  
André
  Mit Zitat antworten Zitat
Benutzerbild von Harry M.
Harry M.

Registriert seit: 29. Okt 2004
Ort: Halle
462 Beiträge
 
#2

Re: Windows Version ermitteln

  Alt 6. Feb 2005, 00:05
versuche die mal nach deinen wünschen umzubauen
Code:
{$IFDEF CONDITIONALEXPRESSIONS}
  {$IF Defined(TOSVersionInfoEx)}
    {$DEFINE TOSVERSIONINFOEX_DEFINED}
  {$IFEND}
{$ENDIF}
{$IFNDEF TOSVERSIONINFOEX_DEFINED}

type
  POSVersionInfoEx = ^TOSVersionInfoEx;
  TOSVersionInfoEx = packed 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;

const
  VER_SERVER_NT                      = $80000000;
  {$EXTERNALSYM VER_SERVER_NT}
  VER_WORKSTATION_NT                 = $40000000;
  {$EXTERNALSYM VER_WORKSTATION_NT}
  VER_SUITE_SMALLBUSINESS            = $00000001;
  {$EXTERNALSYM VER_SUITE_SMALLBUSINESS}
  VER_SUITE_ENTERPRISE               = $00000002;
  {$EXTERNALSYM VER_SUITE_ENTERPRISE}
  VER_SUITE_BACKOFFICE               = $00000004;
  {$EXTERNALSYM VER_SUITE_BACKOFFICE}
  VER_SUITE_COMMUNICATIONS           = $00000008;
  {$EXTERNALSYM VER_SUITE_COMMUNICATIONS}
  VER_SUITE_TERMINAL                 = $00000010;
  {$EXTERNALSYM VER_SUITE_TERMINAL}
  VER_SUITE_SMALLBUSINESS_RESTRICTED = $00000020;
  {$EXTERNALSYM VER_SUITE_SMALLBUSINESS_RESTRICTED}
  VER_SUITE_EMBEDDEDNT               = $00000040;
  {$EXTERNALSYM VER_SUITE_EMBEDDEDNT}
  VER_SUITE_DATACENTER               = $00000080;
  {$EXTERNALSYM VER_SUITE_DATACENTER}
  VER_SUITE_SINGLEUSERTS             = $00000100;
  {$EXTERNALSYM VER_SUITE_SINGLEUSERTS}
  VER_SUITE_PERSONAL                 = $00000200;
  {$EXTERNALSYM VER_SUITE_PERSONAL}
  VER_SUITE_BLADE                    = $00000400;
  {$EXTERNALSYM VER_SUITE_BLADE}
  VER_SUITE_EMBEDDED_RESTRICTED      = $00000800;
  {$EXTERNALSYM VER_SUITE_EMBEDDED_RESTRICTED}
  VER_SUITE_SECURITY_APPLIANCE       = $00001000;
  {$EXTERNALSYM VER_SUITE_SECURITY_APPLIANCE}

const
  VER_NT_WORKSTATION             = $0000001;
  {$EXTERNALSYM VER_NT_WORKSTATION}
  VER_NT_DOMAIN_CONTROLLER       = $0000002;
  {$EXTERNALSYM VER_NT_DOMAIN_CONTROLLER}
  VER_NT_SERVER                  = $0000003;
  {$EXTERNALSYM VER_NT_SERVER}

{$ENDIF}  // TOSVERSIONINFOEX_DEFINED


function GetOSVersionInfo(var Info: TOSVersionInfoEx): Boolean;
begin
  FillChar(Info, SizeOf(TOSVersionInfoEx), 0);
  Info.dwOSVersionInfoSize := SizeOf(TOSVersionInfoEx);
  Result := GetVersionEx(TOSVersionInfo(Addr(Info)^));
  if (not Result) then
  begin
    FillChar(Info, SizeOf(TOSVersionInfoEx), 0);
    Info.dwOSVersionInfoSize := SizeOf(TOSVersionInfoEx);
    Result := GetVersionEx(TOSVersionInfo(Addr(Info)^));
    if (not Result) then
      Info.dwOSVersionInfoSize := 0;
  end;
end;

function GetOSVersionText: string;
var
  Info: TOSVersionInfoEx;
  Key: HKEY;
begin
  Result := '';
  if (not GetOSVersionInfo(Info)) then
    Exit;
  case Info.dwPlatformId of
    { Win32s }
    VER_PLATFORM_WIN32s:
      Result := 'Microsoft Win32s';
    { Windows 9x }
    VER_PLATFORM_WIN32_WINDOWS:
      if (Info.dwMajorVersion = 4) and (Info.dwMinorVersion = 0) then
      begin
        Result := 'Microsoft Windows 95';
        if (Info.szCSDVersion[1] in ['B', 'C']) then
          Result := Result +' OSR2';
      end
      else if (Info.dwMajorVersion = 4) and (Info.dwMinorVersion = 10) then
      begin
        Result := 'Microsoft Windows 98';
        if (Info.szCSDVersion[1] = 'A') then
          Result := Result + ' SE';
      end
      else if (Info.dwMajorVersion = 4) and (Info.dwMinorVersion = 90) then
        Result := 'Microsoft Windows Millennium Edition';
    { Windows NT }
    VER_PLATFORM_WIN32_NT:
      begin
        { Version }
        if (Info.dwMajorVersion = 5) and (Info.dwMinorVersion = 2) then
          Result := 'Microsoft Windows Server 2003'
        else if (Info.dwMajorVersion = 5) and (Info.dwMinorVersion = 1) then
          Result := 'Microsoft Windows XP'
        else if (Info.dwMajorVersion = 5) and (Info.dwMinorVersion = 0) then
          Result := 'Microsoft Windows 2000'
        else
          Result := 'Microsoft Windows NT';
        { Extended }
        if (Info.dwOSVersionInfoSize >= SizeOf(TOSVersionInfoEx)) then
        begin
          { ProductType }
          if (Info.wProductType = VER_NT_WORKSTATION) then
          begin
            if (Info.dwMajorVersion = 4) then
              Result := Result + #10'Workstation 4.0'
            else if(Info.wSuiteMask and VER_SUITE_PERSONAL <> 0) then
              Result := Result + #10'Home Edition'
            else
              Result := Result + #10'Professional';
          end
          else if (Info.wProductType = VER_NT_SERVER) then
          begin
             if (Info.dwMajorVersion = 5) and (Info.dwMinorVersion = 2) then
             begin
               if (Info.wSuiteMask and VER_SUITE_DATACENTER <> 0) then
                 Result := Result + #10'Datacenter Edition'
               else if (Info.wSuiteMask and VER_SUITE_ENTERPRISE <> 0) then
                 Result := Result + #10'Enterprise Edition'
               else if (Info.wSuiteMask = VER_SUITE_BLADE) then
                 Result := Result + #10'Web Edition'
               else
                 Result := Result + #10'Standard Edition';
             end
             else if (Info.dwMajorVersion = 5) and (Info.dwMinorVersion = 0) then
             begin
               if (Info.wSuiteMask and VER_SUITE_DATACENTER <> 0) then
                  Result := Result + #10'Datacenter Server'
               else if (Info.wSuiteMask and VER_SUITE_ENTERPRISE <> 0) then
                  Result := Result + #10'Advanced Server'
               else
                  Result := Result + #10'Server';
             end
             else
             begin
               Result := Result + #10'Server ' +
                 IntToStr(Info.dwMajorVersion) + '.' +
                 IntToStr(Info.dwMinorVersion);
               if (Info.wSuiteMask and VER_SUITE_ENTERPRISE <> 0) then
                 Result := Result + ', Enterprise Edition';
             end;
          end;
        end;
        { CSDVersion }
        if (Info.dwMajorVersion = 4) and
          (StrIComp(Info.szCSDVersion, 'Service Pack 6') = 0) and
          (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
            'SOFTWARE\Microsoft\Windows NT\CurrentVersion\Hotfix\Q246009', 0,
            KEY_QUERY_VALUE, Key) = ERROR_SUCCESS) then
        begin
          Result := Result + #10'Service Pack 6a';
          RegCloseKey(Key);
        end
        else
          Result := Result + #10 + StrPas(Info.szCSDVersion);
        Result := Result + #10'(Build ' +
          IntToStr(Info.dwBuildNumber and $FFFF) + ')';
      end;
  end;
end;

////////////////////////////////////////////////////////////////////////////////

procedure TForm1.Button1Click(Sender: TObject);
begin
  ShowMessage(GetOSVersionText);
end;
Harry
  Mit Zitat antworten Zitat
Benutzerbild von MagicAndre1981
MagicAndre1981

Registriert seit: 4. Jun 2004
Ort: Nordhausen
2.214 Beiträge
 
Delphi 7 Enterprise
 
#3

Re: Windows Version ermitteln

  Alt 6. Feb 2005, 00:23
Hi delphicus,

deine Antwort löst mein Problem auch nicht. Ich habe auf MSDN mal nachgesehen dort folgendes gefunden:
Zitat:
An application running outside Media Center can detect whether it is running in Windows XP Media Center Edition by checking for the SM_MEDIACENTER value in a call to the GetSystemMetrics function. For more information, see GetSystemMetrics on the MSDN Web site.
Wenn man jetzt GetSystemMetrics aufruft will die Fkt. ein Integer als parameter. Wie lautet der Wert für SM_MEDIACENTER?

mfg
André
André
  Mit Zitat antworten Zitat
Robert_G
(Gast)

n/a Beiträge
 
#4

Re: Windows Version ermitteln

  Alt 6. Feb 2005, 00:33
10 Sekunden google ergaben 87.
  Mit Zitat antworten Zitat
Benutzerbild von MagicAndre1981
MagicAndre1981

Registriert seit: 4. Jun 2004
Ort: Nordhausen
2.214 Beiträge
 
Delphi 7 Enterprise
 
#5

Re: Windows Version ermitteln

  Alt 6. Feb 2005, 00:34
Hier die Lösung

die Konstante lautet:
SM_MEDIACENTER = 87;

Delphi-Quellcode:
//
// taken from PSDK Feb 2003 - "Getting the System version"
// (ms-help://MS.PSDK.1033/sysinfo/base/getting_the_system_version.htm)
//
function GetWinVersion: string;
var
  osvi : TOSVersionInfo;
  bOsVersionInfoEx : boolean;
  key : HKEY;
  szProductType : array[0..79]of char;
  dwBuflen : dword;
begin
  // Try calling GetVersionEx using the OSVERSIONINFOEX structure.
  // If that fails, try using the OSVERSIONINFO structure.
  ZeroMemory(@osvi,sizeof(TOSVersionInfo));
  osvi.dwOSVersionInfoSize := sizeof(TOSVersionInfo);

  bOsVersionInfoEx := GetVersionEx(osvi);
  if(not bOsVersionInfoEx) then begin
    osvi.dwOSVersionInfoSize := VERSIONINFOSIZE;

    if(not GetVersionEx(osvi)) then begin
      Result := 'Fehler bei der Ermittlung der Windows-Version';
      exit;
    end;
  end;

  case osvi.dwPlatformId of
    // Test for the Windows NT product family.
    VER_PLATFORM_WIN32_NT:
      begin
        // Test for the specific product family.
        if(osvi.dwMajorVersion = 5) and (osvi.dwMinorVersion = 2) then
          Result := 'Microsoft Windows Server 2003 family, ';

        if(osvi.dwMajorVersion = 5) and (osvi.dwMinorVersion = 1) then
          Result := 'Microsoft Windows XP ';

        if(osvi.dwMajorVersion = 5) and (osvi.dwMinorVersion = 0) then
          Result := 'Microsoft Windows 2000 ';

        if(osvi.dwMajorVersion <= 4) then
          Result := 'Microsoft Windows NT ';

        // Test for specific product on Windows NT 4.0 SP6 and later.
        if(bOsVersionInfoEx) then begin
          // Test for the workstation type.
          if(osvi.wProductType = VER_NT_WORKSTATION) then begin
            if(osvi.dwMajorVersion = 4) then
              Result := Result + 'Workstation 4.0 '
            else if(osvi.wSuiteMask and VER_SUITE_PERSONAL <> 0) then
              Result := Result + 'Home Edition '
            else
            Begin // Unterscheidung zw. MCE und Prof.
              if GetSystemMetrics(SM_MEDIACENTER) <> 0 then
                Result := Result + 'Media Center Edition '
              else
                Result := Result + 'Professional ';
            End;
          end
          // Test for the server type.
          else if(osvi.wProductType = VER_NT_SERVER) then begin
            if(osvi.dwMajorVersion = 5) and
              (osvi.dwMinorVersion = 2) then
            begin // Win 2003
              if(osvi.wSuiteMask and VER_SUITE_DATACENTER <> 0) then
                Result := Result + 'Datacenter Edition '
              else if(osvi.wSuiteMask and VER_SUITE_ENTERPRISE <> 0) then
                Result := Result + 'Enterprise Edition '
              else if(osvi.wSuiteMask = VER_SUITE_BLADE) then
                Result := Result + 'Web Edition '
              else
                Result := Result + 'Standard Edition ';
            end // Win 2000
            else if(osvi.dwMajorVersion = 5) and
              (osvi.dwMinorVersion = 0) then
            begin
              if(osvi.wSuiteMask and VER_SUITE_DATACENTER <> 0) then
                Result := Result + 'Datacenter Server '
              else if(osvi.wSuiteMask and VER_SUITE_ENTERPRISE <> 0) then
                Result := Result + 'Advanced Server '
              else
                Result := Result + 'Server ';
            end
            else begin // Windows NT 4.0
              if(osvi.wSuiteMask and VER_SUITE_ENTERPRISE <> 0) then
                Result := Result + 'Server 4.0, Enterprise Edition '
              else
                Result := Result + 'Server 4.0 ';
            end;
          end
        end
        // Test for specific product on Windows NT 4.0 SP5 and earlier
        else begin
          dwBufLen := sizeof(szProductType);

          if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,
            'SYSTEM\CurrentControlSet\Control\ProductOptions',0,
            KEY_QUERY_VALUE,key) = ERROR_SUCCESS) then
          try
            ZeroMemory(@szProductType,sizeof(szProductType));

            if(RegQueryValueEx(key,'ProductType',nil,nil,
              @szProductType,@dwBufLen) <> ERROR_SUCCESS) or
              (dwBufLen > sizeof(szProductType)) then
            ZeroMemory(@szProductType,sizeof(szProductType));
          finally
            RegCloseKey(key);
          end;

          if(lstrcmpi('WINNT',szProductType) = 0) then
            Result := Result + 'Workstation ';
          if(lstrcmpi('LANMANNT',szProductType) = 0) then
            Result := Result + 'Server ';
          if(lstrcmpi('SERVERNT',szProductType) = 0) then
            Result := Result + 'Advanced Server ';

          Result := Format('%s%d.%d',[Result,osvi.dwMajorVersion,
            osvi.dwMinorVersion]);
        end;

        // Display service pack (if any) and build number.
        if(osvi.dwMajorVersion = 4) and
          (lstrcmpi(osvi.szCSDVersion,'Service Pack 6') = 0) then
        begin
          // Test for SP6 versus SP6a.
          if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,
            'SOFTWARE\Microsoft\Windows NT\CurrentVersion\Hotfix\Q246009',
            0,KEY_QUERY_VALUE,key) = ERROR_SUCCESS) then

            Result := Format('%sService Pack 6a (Build %d)',[Result,
              osvi.dwBuildNumber and $ffff])
          else
            // Windows NT 4.0 prior to SP6a
            Result := Format('%s%s (Build %d)',[Result,
              osvi.szCSDVersion,osvi.dwBuildNumber and $ffff]);
          RegCloseKey(key);
        end
        // Windows NT 3.51 and earlier or Windows 2000 and later
        else begin
          Result := Format('%s%s (Build %d)',[Result,
            osvi.szCSDVersion,osvi.dwBuildNumber and $ffff]);
        end;
      end;
    // Test for the Windows 95 product family.
    VER_PLATFORM_WIN32_WINDOWS:
      begin
        if(osvi.dwMajorVersion = 4) and
          (osvi.dwMinorVersion = 0) then
        begin
          Result := 'Microsoft Windows 95 ';
          if(osvi.szCSDVersion[0] = 'C') or
            (osvi.szCSDVersion[0] = 'B') then Result := Result + 'OSR2 ';
        end;

        if(osvi.dwMajorVersion = 4) and
          (osvi.dwMinorVersion = 10) then
        begin
          Result := 'Microsoft Windows 98 ';
          if(osvi.szCSDVersion[0] = 'A') then Result:= Result + 'SE ';
        end;

        if(osvi.dwMajorVersion = 4) and
          (osvi.dwMinorVersion = 90) then
        begin
          Result := 'Microsoft Windows Millennium Edition';
        end;
      end;
    VER_PLATFORM_WIN32s:
      Result := 'Microsoft Win32s';
  end;
end;
Guten nacht euch allen.
André
André
  Mit Zitat antworten Zitat
Jonas

Registriert seit: 5. Feb 2005
266 Beiträge
 
Delphi 2007 Professional
 
#6

Re: Windows Version ermitteln

  Alt 11. Dez 2005, 21:06
Hi, das funktioniert super. Jedoch hab ich ne Frage. In Windows Vista, werden sind ja unter anderem auch noch andere Editions enhalten. Wenn man das nun unter Vista anwendet, hab ich mir sagen lassen das dort dann Media Center Edition steht, was ich natürlich nicht haben möchte.

http://msdn.microsoft.com/library/de...em_version.asp

Habe ich nach geschaut und bin jedoch nicht fündig geworden, hat jemand ne idee wie man das mit den Versionen herausbekommen kann, bzw Manuell irgendwie dazu schreiben könnte?
  Mit Zitat antworten Zitat
NicoDE
(Gast)

n/a Beiträge
 
#7

Re: Windows Version ermitteln

  Alt 12. Dez 2005, 12:47
Zitat von Jonas:
Habe ich nach geschaut und bin jedoch nicht fündig geworden,
Vista ist noch beta.
(Wenn du es korrekt haben willst, dann kannst du bei > 5.2 'unbekannte Version' schreiben...)
  Mit Zitat antworten Zitat
Jonas

Registriert seit: 5. Feb 2005
266 Beiträge
 
Delphi 2007 Professional
 
#8

Re: Windows Version ermitteln

  Alt 12. Dez 2005, 12:51
Ja das weiß ich.
Ich hab zu 6.0 Vista geschrieben, was auch wunderbar funktioniert. Nur wird ausgelesen das es eine Media Center Edition ist, obwohl es sich um einer Ultimate Edition handelt.
  Mit Zitat antworten Zitat
NicoDE
(Gast)

n/a Beiträge
 
#9

Re: Windows Version ermitteln

  Alt 12. Dez 2005, 12:58
Zitat von Jonas:
Ich hab zu 6.0 Vista geschrieben, was auch wunderbar funktioniert. Nur wird ausgelesen das es eine Media Center Edition ist, obwohl es sich um einer Ultimate Edition handelt.
Steht denn in der Dokumentation zu Vista, dass SM_MEDIACENTER bedeutet, dass es sich um die MCE handelt?
  Mit Zitat antworten Zitat
Benutzerbild von MagicAndre1981
MagicAndre1981

Registriert seit: 4. Jun 2004
Ort: Nordhausen
2.214 Beiträge
 
Delphi 7 Enterprise
 
#10

Re: Windows Version ermitteln

  Alt 12. Dez 2005, 13:24
Zitat von NicoDE:
Steht denn in der Dokumentation zu Vista, dass SM_MEDIACENTER bedeutet, dass es sich um die MCE handelt?
Nee, in der Doku zum Windows SDK für die BETA1 von Vista steht nix drin, wie mann die Versionen von Vista unterscheiden kann. SM_MEDIACENTER bezieht sich nur auf WindowsXP.
André
"A programmer is just a tool which converts caffeine into code", daran wirds wohl liegen, dass ich Abends nie pennen kann

Zitat von Luckie:
Nicht nur dass ihr offtopic geworden seid, jetzt werdet ihr selber im Offtopic noch offtopic
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 1 von 3  1 23      


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 13:25 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