GARANTIR DESCONTO

Fórum Saber a versão do Windows #229090

30/04/2004

0

Galera,

Como faço para saber a versão do windows através do delphi?

No aguardo,


Rvsantos

Rvsantos

Responder

Posts

30/04/2004

Edukobra

const
VER_NT_WORKSTATION = 1;
VER_NT_DOMAIN_CONTROLLER = 2;
VER_NT_SERVER = 3;
VER_SUITE_SMALLBUSINESS = $0001;
VER_SUITE_ENTERPRISE = $0002;
VER_SUITE_BACKOFFICE = $0004;
VER_SUITE_TERMINAL = $0010;
VER_SUITE_SMALLBUSINESS_RESTRICTED = $0020;
VER_SUITE_DATACENTER = $0080;
VER_SUITE_PERSONAL = $0200;
VER_SUITE_BLADE = $0400;

type
TOsVersionInfoEx = packed record
dwOSVersionInfoSize : DWORD;
dwMajorVersion : DWORD;
dwMinorVersion : DWORD;
dwBuildNumber : DWORD;
dwPlatformId : DWORD;
szCSDVersion : array[0..127] of AnsiChar;
wServicePackMajor : Word;
wServicePackMinor : Word;
wSuiteMask : Word;
wProductType : Byte;
wReserved : Byte;
end;

function VersaoWindows: String;
var
osvi : TOSVersionInfoEx;
bOsVersionInfoEx : Boolean;
begin
Result := ´´;
// tenta pegar versao com GetVersionEx
FillChar(osvi, SizeOf(TOSVersionInfoEx), 0);
osvi.dwOSVersionInfoSize := SizeOf(TOSVersionInfoEx);
bOsVersionInfoEx := GetVersionEx(@osvi);
if not bOsVersionInfoEx then
begin
// TOSVersionInfoEx falhou, tenta TOSVersionInfo
osvi.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);
if not GetVersionEx(@osvi) then
exit;
end;
case osvi.dwPlatformId of
// testa para Windows NT
VER_PLATFORM_WIN32_NT:
begin
if osvi.dwMajorVersion <= 4 then
Result := ´Microsoft Windows NT Versão ´ + IntToStr(osvi.dwMajorVersion)
+ ´.´
+ IntToStr(osvi.dwMinorVersion)
else
if (osvi.dwMajorVersion = 5) and(osvi.dwMinorVersion = 0) then
Result := ´Microsoft Windows 2000 ´
else
if (osvi.dwMajorVersion = 5) and (osvi.dwMinorVersion = 1) then
Result := ´Microsoft Windows XP ´
else
if (osvi.dwMajorVersion = 5) and (osvi.dwMinorVersion = 2) then
Result := ´Microsoft Windows 2003 Server ´;
// usa informação de GetVersionEx
if bOsVersionInfoEx then
begin
// Windows workstation
if osvi.wProductType = VER_NT_WORKSTATION then
begin
if (osvi.wSuiteMask and VER_SUITE_PERSONAL) <> 0 then
Result := Result + ´Home Edition ´
else
Result := Result + ´Professional ´;
end
// Windows server
else
if (osvi.wProductType = VER_NT_SERVER) then
begin
if (osvi.wSuiteMask and VER_SUITE_DATACENTER) <> 0 then
Result := Result + ´DataCenter Server ´
else
if (osvi.wSuiteMask and VER_SUITE_ENTERPRISE) <> 0 then
begin
if (osvi.dwMajorVersion = 4) then
Result := Result + ´Advanced Server ´
else
Result := Result + ´Enterprise Server ´;
end
else
if osvi.wSuiteMask = VER_SUITE_BLADE then
Result := Result + ´Web Server ´
else
Result := Result + ´Server ´;
end;
end;
Result := Result + String(osvi.szCSDVersion);
// Retirada em 20/04/2004
// Deixava o resultado muito grande além de ficar carregado demais
// + ´ Compilação: ´+ IntToStr(osvi.dwBuildNumber and $FFFF);
end;
// Windows 95/98/ME
VER_PLATFORM_WIN32_WINDOWS :
begin
if (osvi.dwMajorVersion = 4) and (osvi.dwMinorVersion = 0) then
begin
Result := ´Microsoft Windows 95 ´;
if (osvi.szCSDVersion[1] = ´C´) or (osvi.szCSDVersion[1] = ´B´) then
Result := Result + ´OSR2´;
end
else
if (osvi.dwMajorVersion = 4) and (osvi.dwMinorVersion = 10) then
begin
Result := ´Microsoft Windows 98 ´;
if (osvi.szCSDVersion[1] = ´A´) then
Result := Result + ´SE´;
end
else
if (osvi.dwMajorVersion = 4) and (osvi.dwMinorVersion = 10) then
Result := ´Microsoft Windows Millennium Edition´;
Result := Result;
// Retirada em 20/04/2004
// Deixava o resultado muito grande além de ficar carregado demais
// + ´Compilação: ´ + IntToStr(osvi.dwBuildNumber and $FFFF);
end;
end;
end;


Responder

Gostei + 0

30/04/2004

Carlai

Galera, Como faço para saber a versão do windows através do delphi? No aguardo,

Coloque no uses: Shellapi

{ About padrão do Windows }
ShellAbout(Handle, ´Windows´, ´´, 0);
{ Personalizada }
ShellAbout(Handle, ´NomePrograma´, ´Direitos autorais reservados a´#13´Fulano de Tal´, Application.Icon.Handle);


Responder

Gostei + 0

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar