Solved

Need help detecting the operating system

Posted on 1998-01-13
7
136 Views
Last Modified: 2010-04-04
I need some help to detect whether the OS is Windows95 or Windows NT (which version doesn't matter)

Thanks in Advance,
Ermac


0
Comment
Question by:ermac
7 Comments
 
LVL 2

Expert Comment

by:mvz121697
ID: 1356378
uses
  WinProcs, SysUtils, Dialogs;

var
  Version: record
             case Boolean of
              False: (
                     Windows: record
                                 major: Byte;
                                 minor: Byte;
                               end;
                     DOS: record
                            minor: Byte;
                            major: Byte;
                          end;
                     );
              True: (GetVersion: LongInt);
            end {Version};

begin
  Version.GetVersion := GetVersion;
  if Version.Windows.major < 4 then
    ShowMessage(Format('DOS %d.%-d, Windows %d.%-d',
                       [Version.DOS.major,Version.DOS.minor,
                        Version.Windows.major,Version.Windows.minor]))
  else
    ShowMessage(Format('Windows 95/NT %d.%-d',
                       [Version.Windows.major,Version.Windows.minor]))
end.

When compiled with Delphi 1.02 and run on Windows 95, this program returns "DOS
7.0, Windows 3.95". When compiled with Delphi 2.01 and run on Windows
95, this program returns "Windows 95/NT 4.00", and so it should.
0
 
LVL 5

Expert Comment

by:ronit051397
ID: 1356379
If you use Delphi 2/3 then you can use GetVersionEx:
procedure TForm1.Button1Click(Sender: TObject);
var
  FVer: TOSVERSIONINFO;
begin
  FVer.dwOSVersionInfoSize:=sizeof(TOSVERSIONINFO);
  GetVersionEx(FVer);
  if FVer.dwPlatformId=VER_PLATFORM_WIN32_WINDOWS then
    showmessage('Windows 95 version '+InttoStr(FVer.dwMajorVersion)+'.'+InttoStr(FVer.dwMinorVersion))
  else if FVer.dwPlatformId=VER_PLATFORM_WIN32_NT then
    showmessage('Windows NT version '+InttoStr(FVer.dwMajorVersion)+'.'+InttoStr(FVer.dwMinorVersion))
end;
0
 

Author Comment

by:ermac
ID: 1356380
ronit..

I think your solution is much cleaner...
So how do I give you the points??

Ermac
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 5

Expert Comment

by:ronit051397
ID: 1356381
I'll post some answer.
0
 
LVL 5

Accepted Solution

by:
ronit051397 earned 30 total points
ID: 1356382
Ok, I have posted...
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 2815772
Bought this Q...
0
 
LVL 6

Expert Comment

by:Jaymol
ID: 4536437
So did I
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

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…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

758 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

20 Experts available now in Live!

Get 1:1 Help Now