Solved

How to read if Win2000 or Win95/98?

Posted on 2000-04-05
5
157 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
[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
  • 3
5 Comments
 
LVL 17

Expert Comment

by:inthe
ID: 2687296
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
ID: 2687304
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
ID: 2687306
ps,
ignore winnt5 and the last 5 in dwminorversion..
0
 
LVL 1

Expert Comment

by:yk030299
ID: 2688546
listen
0
 

Author Comment

by:perkley
ID: 2690581
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

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!

Question has a verified solution.

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

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

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