Solved

How to read if Win2000 or Win95/98?

Posted on 2000-04-05
5
155 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Suggested Solutions

Title # Comments Views Activity
Firemonkey webbrowser scrollbars ? 1 57
Can Live bindings change TGrid Cell Colour ? 1 35
IP without any Dots 1 60
Firemonkey Listview item popup menu ? 1 38
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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

730 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