Solved

How to determine OS -  WIN NT or W2K?

Posted on 2001-07-07
4
163 Views
Last Modified: 2010-04-06
In Delphi how can I determine the OS?
I need to determine b/w WIN NT and W2K.
I tried: if Win32Platform = VER_PLATFORM_WIN32_NT then
But this is true for both WIN NT and W2K.
0
Comment
Question by:cjclayton
[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
4 Comments
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 6262078
Hello

 try this procedure

function GetWinVersion: String;
var
  VersionInfo : TOSVersionInfo;
  OSName      : String;
begin
  // set the size of the record
  VersionInfo.dwOSVersionInfoSize := SizeOf( TOSVersionInfo );

  if Windows.GetVersionEx( VersionInfo ) then
     begin
        with VersionInfo do
        begin
           case dwPlatformId of
              VER_PLATFORM_WIN32s   : OSName := 'Win32s';
              VER_PLATFORM_WIN32_WINDOWS : OSName := 'Windows 95';
              VER_PLATFORM_WIN32_NT      : OSName := 'Windows NT';
           end; // case dwPlatformId
           Result := OSName + ' Version ' + IntToStr( dwMajorVersion ) + '.' + IntToStr( dwMinorVersion
) +
                     #13#10' (Build ' + IntToStr( dwBuildNumber ) + ': ' + szCSDVersion + ')';
        end; // with VersionInfo
     end // if GetVersionEx
  else
     Result := '';
end;


procedure TForm1.Button1Click(Sender: TObject);
begin
 ShowMessage(GetWinVersion);
end;

Best regards
Mohammed Nasman
0
 
LVL 22

Accepted Solution

by:
Mohammed Nasman earned 50 total points
ID: 6262219
Here's anoter procedure will tell you if u have win95/win98 or win nt/2000

function GetWinVersion: String;
var
  VerInfo: TOSVersionInfo;
  ResultStr: string;
begin
  ResultStr := '';
  VerInfo.dwOSVersionInfoSize := SizeOf(VerInfo);
  GetVersionEx(VerInfo);
  with VerInfo do
    begin
      case dwPlatformID of
        VER_PLATFORM_WIN32S: ResultStr := ResultStr + 'Windows 3.1x running Win32s ';
        VER_PLATFORM_WIN32_WINDOWS:
          begin
            if IntToStr(dwMajorVersion) + '.' + IntToStr(dwMinorVersion) < '4.10' then
              ResultStr := ResultStr + 'Windows 95 ' + szCSDVersion + ' '
            else
              ResultStr := ResultStr + 'Windows 98 ' + szCSDVersion + ' ';
          end;
        VER_PLATFORM_WIN32_NT:
          begin
            if dwMajorVersion = 5 then
              ResultStr := ResultStr + 'Windows 2000 '
            else
              ResultStr := ResultStr + 'Windows NT ';
          end;
      end;
      ResultStr := ResultStr + IntToStr(dwMajorVersion) + '.' + IntToStr(dwMinorVersion) + ' ';
      ResultStr := ResultStr + '(Build ' +  IntToStr(LoWord(dwBuildNumber)) + ') ';
      if dwPlatformID = VER_PLATFORM_WIN32_NT then
        ResultStr := ResultStr + szCSDVersion;
    end;
  Result := ResultStr;
end;


procedure TForm1.Button1Click(Sender: TObject);
begin
 ShowMessage(GetWinVersion);
end;

Mohammed
0
 
LVL 8

Expert Comment

by:TOndrej
ID: 6265639
Go to www.delphi-jedi.org and download JCL (Jedi Code Library). JclSysInfo unit contains GetWindowsVersion function which I think is complete.
0
 
LVL 20

Expert Comment

by:Madshi
ID: 6268012
Or use my solution, it comes free with sources, too:

http://help.madshi.net/Data/OSInfo.htm

In the next weekend I'll post a new version, which will also know winXP.

Regards, Madshi.
0

Featured Post

Industry Leaders: 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

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

734 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