[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 170
  • Last Modified:

How to determine OS - WIN NT or W2K?

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
cjclayton
Asked:
cjclayton
  • 2
1 Solution
 
Mohammed NasmanSoftware DeveloperCommented:
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
 
Mohammed NasmanSoftware DeveloperCommented:
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
 
TOndrejCommented:
Go to www.delphi-jedi.org and download JCL (Jedi Code Library). JclSysInfo unit contains GetWindowsVersion function which I think is complete.
0
 
MadshiCommented:
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

Independent Software Vendors: 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!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now