Solved

Windows Vista: How to determine which operatingsystem is used

Posted on 2006-11-22
3
295 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

726 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