title image


Smiley GetVersionEx mit TOSVersionInfo(Ex)
////////////////////////////////////////////////////////////////////////////////



type

POSVersionInfoExA = ^TOSVersionInfoExA;

POSVersionInfoExW = ^TOSVersionInfoExW;

POSVersionInfoEx = POSVersionInfoExA;

_OSVERSIONINFOEXA = 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;

{$EXTERNALSYM _OSVERSIONINFOEXA}

_OSVERSIONINFOEXW = packed record

dwOSVersionInfoSize: DWORD;

dwMajorVersion : DWORD;

dwMinorVersion : DWORD;

dwBuildNumber : DWORD;

dwPlatformId : DWORD;

szCSDVersion : array [0..127] of WideChar;

wServicePackMajor : Word;

wServicePackMinor : Word;

wSuiteMask : Word;

wProductType : Byte;

wReserved : Byte;

end;

{$EXTERNALSYM _OSVERSIONINFOEXW}

_OSVERSIONINFOEX = _OSVERSIONINFOEXA;

TOSVersionInfoExA = _OSVERSIONINFOEXA;

TOSVersionInfoExW = _OSVERSIONINFOEXW;

TOSVersionInfoEx = TOSVersionInfoExA;

OSVERSIONINFOEXA = _OSVERSIONINFOEXA;

{$EXTERNALSYM OSVERSIONINFOEXA}

{$EXTERNALSYM OSVERSIONINFOEX}

OSVERSIONINFOEXW = _OSVERSIONINFOEXW;

{$EXTERNALSYM OSVERSIONINFOEXW}

{$EXTERNALSYM OSVERSIONINFOEX}

OSVERSIONINFOEX = OSVERSIONINFOEXA;



const

VER_SERVER_NT = $80000000;

{$EXTERNALSYM VER_SERVER_NT}

VER_WORKSTATION_NT = $40000000;

{$EXTERNALSYM VER_WORKSTATION_NT}



{ wSuiteMask defines }

const

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}



{ wProductType defines }

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}



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



type

TGetVersionExType = (

gvxNone,

gvxStandard,

gvxExtended

);



function MyGetVersionEx(out OsviEx: TOSVersionInfoEx): TGetVersionExType;

var

// alias to variable OsviEx as TOSVersionInfo

Osvi: TOSVersionInfo absolute OsviEx;

begin

Result := gvxNone;

FillChar(OsviEx, SizeOf(OsviEx), 0);

OsviEx.dwOSVersionInfoSize := SizeOf(OsviEx);

if GetVersionEx(Osvi) then

Result := gvxExtended

else

begin

FillChar(OsviEx, SizeOf(OsviEx), 0);

OsviEx.dwOSVersionInfoSize := SizeOf(Osvi);

if GetVersionEx(Osvi) then

Result := gvxStandard;

end;

end;



procedure TForm1.Button1Click(Sender: TObject);

var

OsviEx: TOSVersionInfoEx;

begin

case MyGetVersionEx(OsviEx) of

gvxStandard:

MessageBox(0, 'GetVersionEx returned STANDARD information.',

'MyGetVersionEx', MB_ICONINFORMATION);

gvxExtended:

MessageBox(0, 'GetVersionEx returned EXTENDED information.',

'MyGetVersionEx', MB_ICONINFORMATION);

else

MessageBox(0, 'GetVersionEx returned NO information!',

'MyGetVersionEx', MB_ICONERROR);

end;

end;



Gru/3 Nico



ps: sollte mit D4-6 funktionieren.



geschrieben von

Login

E-Mail:
  

Passwort:
  

Beitrag anfügen

Symbol:
 
 
 
 
 
 
 
 
 
 
 
 
 

Überschrift: