Solved

Need help detecting the operating system

Posted on 1998-01-13
7
139 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

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…
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

828 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