- //Déclarer un type énuméré :
- TWindowsVersion = (twvUnknow, twvWin31, twvWin951, twvWin952, tWvWin981,
- tWvWin982, tWvWinme, tWvWin9x, tWvWinnt35, tWvWinnt4,
- tWvWin2k, tWvWinxp, tWvWinnt);
-
- //*************************************************************
- // Fonction Trouvant la Version de Windows
- //*************************************************************
- function WindowsVersion:TWindowsVersion;
- var
- VI : TOSVersionInfo;
- WinVersion : TWindowsVersion;
- begin
- VI.dwOSVersionInfoSize:= SizeOf(VI);
- GetVersionEx(VI);
-
- WinVersion := twvunknow ;
- case VI.dwPlatformID of
- VER_PLATFORM_WIN32s: WinVersion := tWvWin31;
-
- VER_PLATFORM_WIN32_WINDOWS:
- case VI.dwMinorVersion of
- 0 : if Trim(VI.szCSDVersion[1]) = 'B' then
- WinVersion:= tWvWin952
- else
- WinVersion:= tWvWin951;
- 10 : if Trim(VI.szCSDVersion[1]) = 'A' then
- WinVersion:= tWvWin982
- else
- WinVersion:= tWvWin981;
- 90 : if (VI.dwBuildNumber = 73010104) then
- WinVersion:= tWvWinme;
-
- else WinVersion:= tWvWin9x;
- end;
-
- VER_PLATFORM_WIN32_NT:
- case VI.dwMajorVersion of
- 3 : WinVersion:= tWvWinnt35;
- 4 : WinVersion:= tWvWinnt4;
- 5 : case VI.dwMinorVersion of
- 0 : WinVersion:= tWvWin2k;
- 1 : WinVersion:= tWvWinxp;
- else WinVersion:= tWvWinnt
- end;
- end;
- end;
- result := WinVersion;
- end;
-
- function WindowsVersionStr:string;
- var
- Winver : TWindowsVersion;
- begin
- // on récupère le résultat ainsi:
- // VERSION DE WINDOWS
- WinVer := WindowsVersion;
- Result := 'Inconnu';
- case WinVer of
- twvunknow : Result :='Inconnu';
- twvwin31 : Result :='Windows 3.1';
- twvwin951 : Result :='Windows 95 OSR 1';
- twvwin952 : Result :='Windows 95 OSR 2';
- twvwin981 : Result :='Windows 98 OSR 1';
- twvwin982 : Result :='Windows 98 OSR 2';
- twvwinme : Result :='Windows Me';
- twvwin9x : Result :='Windows 9x'; // Si Windows Inconnu parmi les Win9x
- twvwinnt35 : Result :='Windows NT 3.5';
- twvwinnt4 : Result :='Windows NT 4';
- twvwin2k : Result :='Windows 2000';
- twvwinxp : Result :='Windows XP';
- twvwinnt : Result :='Windows NT'; // Si Windows Inconnu parmi les WinNT
- end;
- end;
-
//Déclarer un type énuméré :
TWindowsVersion = (twvUnknow, twvWin31, twvWin951, twvWin952, tWvWin981,
tWvWin982, tWvWinme, tWvWin9x, tWvWinnt35, tWvWinnt4,
tWvWin2k, tWvWinxp, tWvWinnt);
//*************************************************************
// Fonction Trouvant la Version de Windows
//*************************************************************
function WindowsVersion:TWindowsVersion;
var
VI : TOSVersionInfo;
WinVersion : TWindowsVersion;
begin
VI.dwOSVersionInfoSize:= SizeOf(VI);
GetVersionEx(VI);
WinVersion := twvunknow ;
case VI.dwPlatformID of
VER_PLATFORM_WIN32s: WinVersion := tWvWin31;
VER_PLATFORM_WIN32_WINDOWS:
case VI.dwMinorVersion of
0 : if Trim(VI.szCSDVersion[1]) = 'B' then
WinVersion:= tWvWin952
else
WinVersion:= tWvWin951;
10 : if Trim(VI.szCSDVersion[1]) = 'A' then
WinVersion:= tWvWin982
else
WinVersion:= tWvWin981;
90 : if (VI.dwBuildNumber = 73010104) then
WinVersion:= tWvWinme;
else WinVersion:= tWvWin9x;
end;
VER_PLATFORM_WIN32_NT:
case VI.dwMajorVersion of
3 : WinVersion:= tWvWinnt35;
4 : WinVersion:= tWvWinnt4;
5 : case VI.dwMinorVersion of
0 : WinVersion:= tWvWin2k;
1 : WinVersion:= tWvWinxp;
else WinVersion:= tWvWinnt
end;
end;
end;
result := WinVersion;
end;
function WindowsVersionStr:string;
var
Winver : TWindowsVersion;
begin
// on récupère le résultat ainsi:
// VERSION DE WINDOWS
WinVer := WindowsVersion;
Result := 'Inconnu';
case WinVer of
twvunknow : Result :='Inconnu';
twvwin31 : Result :='Windows 3.1';
twvwin951 : Result :='Windows 95 OSR 1';
twvwin952 : Result :='Windows 95 OSR 2';
twvwin981 : Result :='Windows 98 OSR 1';
twvwin982 : Result :='Windows 98 OSR 2';
twvwinme : Result :='Windows Me';
twvwin9x : Result :='Windows 9x'; // Si Windows Inconnu parmi les Win9x
twvwinnt35 : Result :='Windows NT 3.5';
twvwinnt4 : Result :='Windows NT 4';
twvwin2k : Result :='Windows 2000';
twvwinxp : Result :='Windows XP';
twvwinnt : Result :='Windows NT'; // Si Windows Inconnu parmi les WinNT
end;
end;