?
Solved

Distinguish between Win9x and NT

Posted on 1999-12-23
4
Medium Priority
?
229 Views
Last Modified: 2010-04-06
Hi,
Are there any ways to distinguish the OS between Windows 9x and Windows NT?  (Ways not involving the registry preferred.)
(D2)
0
Comment
Question by:yingkit
  • 2
4 Comments
 
LVL 2

Expert Comment

by:hubdog
ID: 2304805
The GetVersionEx function obtains extended information about the version of the operating system that is currently running.

BOOL GetVersionEx(

    LPOSVERSIONINFO lpVersionInformation       // pointer to version information structure
   );      
 
0
 
LVL 2

Expert Comment

by:hubdog
ID: 2304847
{$IFDEF WIN32}
function GetVersionEx(lpOs : pointer) : BOOL; stdcall;
 external 'kernel32' name 'GetVersionExA';
{$ENDIF}

procedure GetWindowsVersion(var Major : integer;
                            var Minor : integer);
var
 {$IFDEF WIN32}
  lpOS, lpOS2 : POsVersionInfo;
 {$ELSE}
  l : longint;
 {$ENDIF}
begin
 {$IFDEF WIN32}
   GetMem(lpOS, SizeOf(TOsVersionInfo));
   lpOs^.dwOSVersionInfoSize := SizeOf(TOsVersionInfo);
   while getVersionEx(lpOS) = false do begin
     GetMem(lpos2, lpos^.dwOSVersionInfoSize + 1);
     lpOs2^.dwOSVersionInfoSize := lpOs^.dwOSVersionInfoSize + 1;
     FreeMem(lpOs, lpOs^.dwOSVersionInfoSize);
     lpOS := lpOs2;
   end;
   Major := lpOs^.dwMajorVersion;
   Minor := lpOs^.dwMinorVersion;
   FreeMem(lpOs, lpOs^.dwOSVersionInfoSize);
 {$ELSE}
  l := GetVersion;
  Major := LoByte(LoWord(l));
  Minor := HiByte(LoWord(l));
 {$ENDIF}
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  Major : integer;
  Minor : integer;
begin
  GetWindowsVersion(Major, Minor);
  Memo1.Lines.Add(IntToStr(Major));
  Memo1.Lines.Add(IntToStr(Minor));
end;
0
 

Author Comment

by:yingkit
ID: 2304857
I tried it on a NT machine, however, the program said that kernel32 cound not be found in the specified path........some paths here.
When it was run in a Win95 machine, memo1 only gave two numbers, 4 and 0
What will be the numbers if the program is run under NT?
0
 
LVL 20

Accepted Solution

by:
Madshi earned 200 total points
ID: 2304904
uses SysUtils;

  if Win32Platform = VER_PLATFORM_WIN32_WINDOWS then
    ShowMessage('win9x');
  if Win32Platform = VER_PLATFORM_WIN32_NT then
    ShowMessage('winNT');

Regards, Madshi.
0

Featured Post

2018 Annual Membership Survey

Here at Experts Exchange, we strive to give members the best experience. Help us improve the site by taking this survey today! (Bonus: Be entered to win a great tech prize for participating!)

Question has a verified solution.

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

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…
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…
The video will let you know the exact process to import OST/PST files to the cloud based Office 365 mailboxes. Using Kernel Import PST to Office 365 tool, one can quickly import numerous OST/PST files to Office 365. Besides this, the tool also comes…
Free Data Recovery software is an advanced solution from Kernel Tools to recover data and files such as documents, emails, database, media and pictures, etc. It supports recovery from physical & logical drive after a hard disk crash, accidental/inte…

601 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