![]() |
VerifyVersionInfo liefert immer False
Ich habe die API-Funktion VerifyVersionInfo
Delphi-Quellcode:
Aber die liefert mir immer False zurück, obwohl ich Windows XP SP2 habe, wo sie eigentlich True liefern sollte. Woran liegt das? :gruebel:
type
DWORDLONG = Int64; 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_EQUAL = 1; // The current value must be equal to the specified value. VER_GREATER = 2; // The current value must be greater than the specified value. VER_GREATER_EQUAL = 3; // The current value must be greater than or equal to the specified value. VER_LESS = 4; // The current value must be less than the specified value. VER_LESS_EQUAL = 5; // The current value must be less than or equal to the specified value. VER_AND = 6; // All product suites specified in the wSuiteMask member must be present in the current system. VER_OR = 7; // At least one of the specified product suites must be present in the current system. VER_BUILDNUMBER = $0000004; // dwBuildNumber VER_MAJORVERSION = $0000002; // dwMajorVersion If you are testing the major version, you must also test // the minor version and the service pack version. VER_MINORVERSION = $0000001; // dwMinorVersion VER_PLATFORMID = $0000008; // dwPlatformId VER_SERVICEPACKMAJOR = $0000020; // wServicePackMajor VER_SERVICEPACKMINOR = $0000010; // wServicePackMinor VER_SUITENAME = $0000040; // wSuiteMask VER_PRODUCT_TYPE = $0000080; // wProductType function VerifyVersionInfoW(var VersionInfo: TOSVersionInfoEx; TypeMask: DWORD; Conditionalmask: DWORDLONG): BOOL; stdcall; external 'kernel32.dll'; function VerSetConditionMask(dwlConditionMask: LONGLONG; TypeBitMask: DWORD; ConditionMask: Byte): LONGLONG; stdcall; external 'kernel32.dll'; function IsWinXPOrLater: BOOL; var osvi : TOSVersionInfoEx; ConditionMask : DWORD; op : Integer; begin ConditionMask := 0; op := VER_GREATER_EQUAL; ZeroMemory(@osvi, sizeof(TOSVersionInfoEx)); osvi.dwOSVersionInfoSize := sizeof(TOSVersioNinfoEx); osvi.dwMajorVersion := 5; osvi.dwMinorVersion := 1; osvi.wServicePackMajor := 2; osvi.wServicePackMinor := 0; VerSetConditionMask(ConditionMask, VER_MAJORVERSION, op); VerSetConditionMask(ConditionMask, VER_MINORVERSION, op); VerSetConditionMask(ConditionMask, VER_SERVICEPACKMAJOR, op); VerSetConditionMask(ConditionMask, VER_SERVICEPACKMINOR, op); result := VerifyVersionInfoW(osvi, VER_MAJORVERSION or VER_MINORVERSION or VER_SERVICEPACKMAJOR or VER_SERVICEPACKMINOR, ConditionMask); end; procedure TForm1.Button1Click(Sender: TObject); var res : BOOL; begin res := IsWinXPOrLater; if res then ShowMessage('XP SP1 oder höher') else ShowMessage('Nicht Win XP SP1 oder höher'); end; |
Re: VerifyVersionInfo liefert immer False
VerSetConditionMask liefert doch einen Rückgabewert, der bei dir nun im nichts versickert...
Delphi-Quellcode:
funzt es so ?
begin
op := VER_GREATER_EQUAL; ZeroMemory(@osvi, sizeof(TOSVersionInfoEx)); osvi.dwOSVersionInfoSize := sizeof(TOSVersioNinfoEx); osvi.dwMajorVersion := 5; osvi.dwMinorVersion := 1; osvi.wServicePackMajor := 2; osvi.wServicePackMinor := 0; // Von hier... ConditionMask := 0; ConditionMask := VerSetConditionMask(ConditionMask, VER_MAJORVERSION, op); ConditionMask := VerSetConditionMask(ConditionMask, VER_MINORVERSION, op); ConditionMask := VerSetConditionMask(ConditionMask, VER_SERVICEPACKMAJOR, op); ConditionMask := VerSetConditionMask(ConditionMask, VER_SERVICEPACKMINOR, op); // ...bis hier geändert result := VerifyVersionInfoW(osvi, VER_MAJORVERSION or VER_MINORVERSION or VER_SERVICEPACKMAJOR or VER_SERVICEPACKMINOR, ConditionMask); end; |
Re: VerifyVersionInfo liefert immer False
Hallo Michael,
beim Verwerfen des Funktions-Rückgabewertes hast du wohl übersehen, dass das Beispiel im PSDK das Makro verwendet und nicht die API-Funktion, aber das hat dir Basilikum ja schon gezeigt. Nur der Ordnung halber - ConditionMask sollte nicht DWORD sondern DWORDLONG sein, hast den Typ doch extra deklariert. Und die Abfrage von ServicePacks unter XP funktioniert nicht, auch wenn der Platform SDK anderes behauptet. Du wirst es merken, wenn du dein System befragst:
Delphi-Quellcode:
Übrigens: Der ServicePack-Test (wenn er denn funktionieren würde) und dein Meldungstext harmonieren nicht so ganz.
if not WinXPorLater then ShowMessage(SysErrorMessage(GetLastError));
Freundliche Grüße vom marabu |
Re: VerifyVersionInfo liefert immer False
Zitat:
Zitat:
Delphi-Quellcode:
Man sollte so spät nicht mehr programmieren. ;)
type
DWORDLONG = Int64; 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_EQUAL = 1; // The current value must be equal to the specified value. VER_GREATER = 2; // The current value must be greater than the specified value. VER_GREATER_EQUAL = 3; // The current value must be greater than or equal to the specified value. VER_LESS = 4; // The current value must be less than the specified value. VER_LESS_EQUAL = 5; // The current value must be less than or equal to the specified value. VER_AND = 6; // All product suites specified in the wSuiteMask member must be present in the current system. VER_OR = 7; // At least one of the specified product suites must be present in the current system. VER_BUILDNUMBER = $0000004; // dwBuildNumber VER_MAJORVERSION = $0000002; // dwMajorVersion If you are testing the major version, you must also test // the minor version and the service pack version. VER_MINORVERSION = $0000001; // dwMinorVersion VER_PLATFORMID = $0000008; // dwPlatformId VER_SERVICEPACKMAJOR = $0000020; // wServicePackMajor VER_SERVICEPACKMINOR = $0000010; // wServicePackMinor VER_SUITENAME = $0000040; // wSuiteMask VER_PRODUCT_TYPE = $0000080; // wProductType function VerifyVersionInfoW(var VersionInfo: TOSVersionInfoEx; TypeMask: DWORD; Conditionalmask: DWORDLONG): BOOL; stdcall; external 'kernel32.dll'; function VerSetConditionMask(dwlConditionMask: LONGLONG; TypeBitMask: DWORD; ConditionMask: Byte): LONGLONG; stdcall; external 'kernel32.dll'; function IsWinXPOrLater: BOOL; var osvi : TOSVersionInfoEx; ConditionMask : DWORDLONG; op : Integer; begin op := VER_GREATER_EQUAL; ZeroMemory(@osvi, sizeof(TOSVersionInfoEx)); osvi.dwOSVersionInfoSize := sizeof(TOSVersioNinfoEx); osvi.dwMajorVersion := 5; osvi.dwMinorVersion := 1; ConditionMask := 0; ConditionMask := VerSetConditionMask(ConditionMask, VER_MAJORVERSION, op); ConditionMask := VerSetConditionMask(ConditionMask, VER_MINORVERSION, op); result := VerifyVersionInfoW(osvi, VER_MAJORVERSION or VER_MINORVERSION, ConditionMask); end; procedure TForm1.Button1Click(Sender: TObject); var res : BOOL; begin res := IsWinXPOrLater; if res then ShowMessage('XP oder höher') else ShowMessage('Nicht Win XP oder höher'); end; |
Re: VerifyVersionInfo liefert immer False
Liste der Anhänge anzeigen (Anzahl: 1)
So, dafür habe ich das gebraucht: Artikel -
![]() |
AW: Re: VerifyVersionInfo liefert immer False
Toll, da hört man mal auf's MSDN
Zitat:
![]() Und Hilfestellungen findet man über ![]() Kein Wunder ... wozu auch umständlich, wenn auch 'nen Einzeiler ausreicht. :wall: |
Alle Zeitangaben in WEZ +1. Es ist jetzt 13:23 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz