 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
marios Guest
|
Posted: Sun Feb 04, 2007 9:11 am Post subject: How to detect VISTA |
|
|
Hi ,
I have been using the follwoing code to detect if XP is running on a given
system.
I now need to detect VISTA . What is required to modify the code below.
I have no idea what to look for now? Google has been of no help.
Any suggestions would be greatly welcome
Marios
-------------------------------
function GetWinType(FName : PChar; W, H : integer ) : integer; stdcall;
var
OSVersion : TOSVersionInfo;
WinVersion: Integer;
begin
OSVersion.dwOSVersionInfoSize := sizeof(OSVersion);
GetVersionEx(OSVersion);
result :=0;
if OSVersion.dwPlatformId=VER_PLATFORM_WIN32_NT then
begin
if (OSVersion.dwMajorVersion >= 5) and (OSVersion.dwMinorVersion >= 1)
and (OSVersion.dwPlatformId = VER_PLATFORM_WIN32_NT) then
begin
result :=1 ;
end;
end;
end; |
|
| Back to top |
|
 |
Matt Lacey Guest
|
Posted: Wed Feb 14, 2007 10:41 pm Post subject: Re: How to detect VISTA |
|
|
On 4 Feb, 03:55, "marios" <mar...@email.msn.com> wrote:
| Quote: | Hi ,
I have been using the follwoing code to detect if XP is running on a given
system.
I now need to detect VISTA . What is required to modify the code below.
I have no idea what to look for now? Google has been of no help.
Any suggestions would be greatly welcome
Marios
-------------------------------
function GetWinType(FName : PChar; W, H : integer ) : integer; stdcall;
var
OSVersion : TOSVersionInfo;
WinVersion: Integer;
begin
OSVersion.dwOSVersionInfoSize := sizeof(OSVersion);
GetVersionEx(OSVersion);
result :=0;
if OSVersion.dwPlatformId=VER_PLATFORM_WIN32_NT then
begin
if (OSVersion.dwMajorVersion >= 5) and (OSVersion.dwMinorVersion >= 1)
and (OSVersion.dwPlatformId = VER_PLATFORM_WIN32_NT) then
begin
result :=1 ;
end;
end;
end;
|
Despite it's name, your function seems to return 1 if running on XP
and 0 if not.
To detect OS versions I use the constants Win32MajorVersion,
Win32MinorVersion and Win32Platform in SysUtils
Vista has a major version of 6.
Therefore:
function IsVista(): Boolean;
begin
result := Win32MajorVersion = 6;
end;
Disclaimer: This is not guaranteed to be accurate once LongHorn (or
any other new Microsoft operating system) comes out. |
|
| Back to top |
|
 |
Powered by phpBB © 2001, 2006 phpBB Group .
|