Windows with Delphi Windows API (94) Windows Filesystem (41) Windows Forms (69) Windows Graphics (38)
Exchange Links About this site Links to us 
New related comments Number of comments in the last 48 hoursPlay WAV files 1 new comments
|
Determine what version of Windows a PC is running
This article has not been rated yet. After reading, feel free to leave comments and rate it.
Do you need to determine what version of Windows a PC is running? The following code will work on all (Windows) platforms with Delphi 1 (16 bit) to Delphi 5 (32 bit).
It will distinguish between Windows 2000, NT, Windows 98, 95 and even Windows 3.1/ Windows for Workgroups.  | |  | | function WinSystem : String;
var
OSVersion : TOSVersionInfo;
WinVersion: String;
OrdHigh : DWORD;
OrdLow : DWORD;
begin
OSVersion.dwOSVersionInfoSize := sizeof(OSVersion);
GetVersionEx(OSVersion);
OrdHigh := (OSVersion.dwBuildNumber shr 24) and $FF;
OrdLow := (OSVersion.dwBuildNumber shr 16) and $FF;
if OSVersion.dwPlatformId=VER_PLATFORM_WIN32_NT then
begin
if (OrdHigh>=5) then
begin
WinVersion := 'Windows 2000'
end
else
begin
WinVersion := 'Windows NT'
end;
end;
if OSVersion.dwPlatformId=VER_PLATFORM_WIN32_WINDOWS then
begin
if (OrdLow>=90) or (OrdHigh>=5) then
begin
WinVersion := 'Windows Millennium'
end;
if (OrdLow>=10) and (OrdLow<90) then
begin
WinVersion := 'Windows 98'
end;
if (OrdLow<10) then
begin
WinVersion := 'Windows 95'
end;
if (OrdLow<5) then
begin
WinVersion := 'Windows 3.1/ WfWg'
end;
end;
Result := WinVersion;
end; | |  | |  | You don't like the formatting? Check out SourceCoder then!
Comments:
|