Solved

Windows Vista: How to determine which operatingsystem is used

Posted on 2006-11-22
3
288 Views
Last Modified: 2010-04-16
Hi,

Can anybody tell me how to determine if a user runs on Windows Vista?

For other operatingsystem I already have a solution. See below:

function GetSystemType: Integer;
const
  { operating system constants }
  cOsUnknown = -1;
  cOsWin95   = 0;
  cOsWin98   = 1;
  cOsWin98SE = 2;
  cOsWinME   = 3;
  cOsWinNT   = 4;
  cOsWin2000 = 5;
  cOsWinXP   = 6;
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 := cOsWinXP
            else
            result := cOsUnknown;
          end; {case }
      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 {if Version = 'A'}
              else
                if (majorVer = 4) AND (minorVer = 90) then
                  result := cOsWinME
                else
                   result := cOsUnknown;
        end; {case VER_PLATFORM_WIN32_WINDOWS}
      else
       result := cOsUnknown;
    end;
  end
else
   result := cOsUnknown;
end;


Regards,
Stef
0
Comment
Question by:Delphiwizard
  • 2
3 Comments
 
LVL 19

Accepted Solution

by:
MerijnB earned 500 total points
ID: 17994243
see this VB code snippet, I assume you can translate it?

  if Win32Platform = VER_PLATFORM_WIN32_NT then
    begin
      if (osvi.dwMajorVersion = 6) and (osvi.dwMinorVersion = 0) then
        Result := 'Microsoft Windows Vista '
      else if (osvi.dwMajorVersion = 5) and (osvi.dwMinorVersion = 2) then
        Result := 'Microsoft Windows Server 2003 family, '
      else if (osvi.dwMajorVersion = 5) and (osvi.dwMinorVersion = 1) then
        Result := 'Microsoft Windows XP '
      else if (osvi.dwMajorVersion = 5) and (osvi.dwMinorVersion = 0) then
        Result := 'Microsoft Windows 2000 '
      else if osvi.dwMajorVersion <= 4 then
        Result := 'Microsoft Windows NT ';
0
 
LVL 19

Expert Comment

by:MerijnB
ID: 17994247
VB? What was I thinking... it's just delphi :)
0
 

Author Comment

by:Delphiwizard
ID: 17994365
Thank you very much.
Stef
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now