Solved

Need help detecting the operating system

Posted on 1998-01-13
7
141 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
[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
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
Technology Partners: 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!

 
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

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

717 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