Solved

How to determine OS -  WIN NT or W2K?

Posted on 2001-07-07
4
157 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
  • 2
4 Comments
 
LVL 22

Expert Comment

by:mnasman
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:
mnasman 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

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
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.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

746 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

13 Experts available now in Live!

Get 1:1 Help Now