Connaitre la version de Windows

const
{ operating system const ants }
cOsUnknown = -1;
cOsWin95 = 0;
cOsWin98 = 1;
cOsWin98SE = 2;
cOsWinME = 3;
cOsWinNT = 4;
cOsWin2000 = 5;
cOsWhistler = 6;


function GetOperatingSystem: integer;
var
osVerInfo: TOSVersionInfo;
majorVer, minorVer: Integer;
begin
result := cOsUnknown;
{ set operating system type flag }
osVerInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);
if GetVersionEx(osVerInfo) then
begin
majorVer := osVerInfo.dwMajorVersion;
minorVer := osVerInfo.dwMinorVersion;
case osVerInfo.dwPlatformId of VER_PLATFORM_WIN32_NT: { Windows NT/2000 }
begin
if majorVer <= 4 then
result := cOsWinNT
else if (majorVer = 5) and (minorVer = 0) then
result := cOsWin2000
else if (majorVer = 5) and (minorVer = 1) then
result := cOsWhistler
else
result := cOsUnknown;
end;
VER_PLATFORM_WIN32_WINDOWS: { Windows 9x/ME }
begin
if (majorVer = 4) and (minorVer = 0) then
result := cOsWin95
else if (majorVer = 4) and (minorVer = 10) then
begin
if osVerInfo.szCSDVersion[1] = 'A' then
result := cOsWin98SE
else
result := cOsWin98;
end
else if (majorVer = 4) and (minorVer = 90) then
result := cOsWinME
else
result := cOsUnknown;
end;
else
result := cOsUnknown;
end;
end
else
result := cOsUnknown;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
ShowMessage(IntToStr(GetOperatingSystem));
end;
Ajouter un commentaire
Pseudo
Adresse email
Site internet (optionnel)
Votre commentaire
Fiche de l'article
Mise a jour12/11/2001
VisualisationVu 934 fois
PublicInternaute zz
CategorieDelphi - Trucs et astuces - Systeme
Auteur de l'article
Communauté Delphi Communauté Delphi
connecté le 02/11/2011
0 articles dans la section
Contacter l'auteur