?
Solved

How to determine OS -  WIN NT or W2K?

Posted on 2001-07-07
4
Medium Priority
?
166 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 150 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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

762 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