Solved

How to read if Win2000 or Win95/98?

Posted on 2000-04-05
5
148 Views
Last Modified: 2010-04-04
I currently use this code to show the information for Windows 95 and 98.

var
  Reg: TRegistry;

begin
  Reg := TRegistry.Create;

  Reg.RootKey := HKEY_LOCAL_MACHINE;
  if Reg.OpenKey('\SOFTWARE\Microsoft\Windows\CurrentVersion', FALSE)
  then lblOSVersion.Caption := Reg.ReadString('Version') +' (Build: '+Reg.ReadString('VersionNumber')+')';
  Reg.Free;

This works great, unfortunately I do not have Windows NT or 2000 to play around with to make it work on those platforms.  I have tried my program on those systems, and when I visit the about box, nothing comes up for the Platform.

What do I need to do to get it to display Windows 2000 or Windows NT or Win95 and Win98 depending on what machine they are on?
0
Comment
Question by:perkley
  • 3
5 Comments
 
LVL 17

Expert Comment

by:inthe
Comment Utility
procedure TForm1.Button1Click(Sender: TObject);
var
OS : TOSVersionInfo;
begin
OS.dwOSVersionInfoSize := sizeof(OS);
GetVersionEx(OS);
with OS do
    case dwPlatformId of
        VER_PLATFORM_WIN32s :
              label1.caption := 'Windows 3.1x/32s';
        VER_PLATFORM_WIN32_WINDOWS :
            Begin
                if (dwMajorVersion = 4) and (dwMinorVersion > 0) then begin
               label1.caption := 'Windows 98';
               label2.caption := inttostr(dwMajorVersion);
               label3.caption := inttostr(dwMinorVersion);
               label4.caption := inttostr(dwPlatformID);
               label5.caption := inttostr(loword(dwBuildNumber));
               label6.caption := os.szCSDVersion;
                end
              else
                label1.caption := 'Windows 95';
            end;
        VER_PLATFORM_WIN32_NT :

          label1.caption := 'Windows NT' ;
      end;
  end;

i suspect this next part may not format on e.e corrctly but it is list of most major/minor versions to check for in your function

            Win95      Win3.11      Win98      Win98SE      Winnt3.51      Winnt4.0      Win2000      Winnt5

dwPlatFormID              1      1      1      1      2      2            

dwMajorVersion             4            4      4      3      4      5      5

dwMinorVersion            0            10      10      51      0      0      
0
 
LVL 17

Accepted Solution

by:
inthe earned 50 total points
Comment Utility
so you add to function:

if (dwMajorVersion = 5) and (dwMinorVersion > 0) and (dwPlatformID = 2)  then
               label1.caption := 'Windows 2000';


etc...
0
 
LVL 17

Expert Comment

by:inthe
Comment Utility
ps,
ignore winnt5 and the last 5 in dwminorversion..
0
 
LVL 1

Expert Comment

by:yk030299
Comment Utility
listen
0
 

Author Comment

by:perkley
Comment Utility
Thank you very much, it worked well, except that when I tried it on a Win2000 machine it said it was Windows NT.

The Win2000 had a dwMinorVersion = 0, so your function that you mentioned above worked except that I had to change it to = 0, not > 0.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

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…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

744 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

18 Experts available now in Live!

Get 1:1 Help Now