Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to determine OS -  WIN NT or W2K?

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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

636 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