Como verificar a versão do Windows instalada?
É necessário estar declarado Windows na seção uses,
em versões unicode declare Winapi.Windows.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
| function GetOSVersion(var MajorVersion, MinorVersion, Build: DWORD) : String;
var
VersionInfo: TOSVersionInfo;
vPlatform: string;
begin
VersionInfo.dwOSVersionInfoSize := SizeOf(VersionInfo);
GetVersionEx(VersionInfo);
with VersionInfo do
begin
case dwPlatformId of
VER_PLATFORM_WIN32s:
vPlatform := 'Windows 3x';
VER_PLATFORM_WIN32_WINDOWS:
vPlatform := 'Windows 95';
VER_PLATFORM_WIN32_NT:
vPlatform := 'Windows NT'; // 2000, XP, Vista, 7, 8, 8.1
end;
MajorVersion := dwMajorVersion;
MinorVersion := dwMinorVersion;
Build := dwBuildNumber;
Result := vPlatform;
end;
end; |
function GetOSVersion(var MajorVersion, MinorVersion, Build: DWORD) : String;
var
VersionInfo: TOSVersionInfo;
vPlatform: string;
begin
VersionInfo.dwOSVersionInfoSize := SizeOf(VersionInfo);
GetVersionEx(VersionInfo);
with VersionInfo do
begin
case dwPlatformId of
VER_PLATFORM_WIN32s:
vPlatform := 'Windows 3x';
VER_PLATFORM_WIN32_WINDOWS:
vPlatform := 'Windows 95';
VER_PLATFORM_WIN32_NT:
vPlatform := 'Windows NT'; // 2000, XP, Vista, 7, 8, 8.1
end;
MajorVersion := dwMajorVersion;
MinorVersion := dwMinorVersion;
Build := dwBuildNumber;
Result := vPlatform;
end;
end;
Exemplo de uso.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| procedure TForm1.Button2Click(Sender: TObject);
var
MajorVersion, MinorVersion, Build: DWORD;
begin
ShowMessage(GetOSVersion(MajorVersion, MinorVersion, Build));
if ((MajorVersion = 5) and (MinorVersion = 0)) then
ShowMessage('Windows 2000 Build: ' + IntToStr(Build));
if ((MajorVersion = 5) and (MinorVersion = 1)) then
ShowMessage('Windows XP Build: ' + IntToStr(Build));
if ((MajorVersion = 6) and (MinorVersion = 0)) then
ShowMessage('Windows Vista Build: ' + IntToStr(Build));
if ((MajorVersion = 6) and (MinorVersion = 1)) then
ShowMessage('Windows 7 Build: ' + IntToStr(Build));
if ((MajorVersion = 6) and (MinorVersion = 2)) then
ShowMessage('Windows 8 Build: ' + IntToStr(Build));
end; |
procedure TForm1.Button2Click(Sender: TObject);
var
MajorVersion, MinorVersion, Build: DWORD;
begin
ShowMessage(GetOSVersion(MajorVersion, MinorVersion, Build));
if ((MajorVersion = 5) and (MinorVersion = 0)) then
ShowMessage('Windows 2000 Build: ' + IntToStr(Build));
if ((MajorVersion = 5) and (MinorVersion = 1)) then
ShowMessage('Windows XP Build: ' + IntToStr(Build));
if ((MajorVersion = 6) and (MinorVersion = 0)) then
ShowMessage('Windows Vista Build: ' + IntToStr(Build));
if ((MajorVersion = 6) and (MinorVersion = 1)) then
ShowMessage('Windows 7 Build: ' + IntToStr(Build));
if ((MajorVersion = 6) and (MinorVersion = 2)) then
ShowMessage('Windows 8 Build: ' + IntToStr(Build));
end;
-
InfusTec
-
7.839 views
- 0 comentários
- 7 de abril de 2015
Está gostando do conteúdo? Considere pagar um cafezinho para nossa equipe!
Posts Relacionados - Continue Aprendendo