uses Registry;
function winvers: byte;
var
reg: TRegistry;
build, buildx: string;
begin
result := 0;
Reg := TRegistry.Create;
try
Reg.RootKey := HKEY_LOCAL_MACHINE;
if Reg.OpenKey('\SOFTWARE\Microsoft\Windows NT\CurrentVersion', False)
then begin
build := Reg.ReadString('BuildLab');
buildx := Reg.ReadString('BuildLabEx');
if pos('xp', build) > 0 then result := 1
else if pos('win7', build) > 0 then begin
if pos('x86', buildx) > 0 then result := 2
else result := 3;
end;
end;
finally
Reg.CloseKey;
Reg.Free;
end;
end;
// Beispielaufruf
procedure TForm1.Button1Click(Sender: TObject);
begin
case winvers of
1: label2.caption := 'XP';
2: label2.caption := 'W7 32Bit';
3: label2.caption := 'W7 64Bit';
else label2.caption := 'Kein XP und kein W7';
end;
end;