?
Solved

How to read if Win2000 or Win95/98?

Posted on 2000-04-05
5
Medium Priority
?
164 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
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 200 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
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…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

850 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