Board index » delphi » function for detecting windows system (Win3.1, Win95/98, Win NT)

function for detecting windows system (Win3.1, Win95/98, Win NT)

On Thu, 13 Jan 2000 16:43:20 +0100 Danjel Grosar wrote:

Quote
> http://servis.saop.si/Danjel/Cblip.htm

1) Stop posting HTML.
2) Try this function. It's from a great (but not my) german FAQ
http://pics.webset.de/faq.htm:

function GetWindowsVersion:string;
var
  OsVinfo   : TOSVERSIONINFO;
  HilfStr   : array[0..50] of Char;
begin
  ZeroMemory(@OsVinfo,sizeOf(OsVinfo));
  OsVinfo.dwOSVersionInfoSize := sizeof(TOSVERSIONINFO);
  if GetVersionEx(OsVinfo) then begin
    if OsVinfo.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS then
     begin
      if (OsVinfo.dwMajorVersion = 4) and
       (OsVinfo.dwMinorVersion > 0) then
        StrFmt(HilfStr,'Windows 98 - Version %d.%.2d.%d',
               [OsVinfo.dwMajorVersion, OsVinfo.dwMinorVersion,
                OsVinfo.dwBuildNumber AND $FFFF])
      else
        StrFmt(HilfStr,'Windows 95 - Version %d.%d Build %d',
               [OsVinfo.dwMajorVersion, OsVinfo.dwMinorVersion,
                OsVinfo.dwBuildNumber AND $FFFF]);
    end;
    if OsVinfo.dwPlatformId = VER_PLATFORM_WIN32_NT then
      StrFmt(HilfStr,'Microsoft Windows NT Version %d.%.2d.%d',
             [OsVinfo.dwMajorVersion, OsVinfo.dwMinorVersion,
              OsVinfo.dwBuildNumber AND $FFFF]);
  end
  else
    StrCopy(HilfStr,'Error while executing GetversionEx()!');
  Result:=string(HilfStr);
end;

Bye, Udo

 

Re:function for detecting windows system (Win3.1, Win95/98, Win NT)


The Windows version detected is available in the SYSUTILS.PAS unit,
you don't need to go out and call a function to get it!

var
{ Win32 platform identifier.  This will be one of the following
values:
    VER_PLATFORM_WIN32s
    VER_PLATFORM_WIN32_WINDOWS
    VER_PLATFORM_WIN32_NT
  See WINDOWS.PAS for the numerical values. }
 Win32Platform: Integer = 0;

{ Win32 OS version information -
  see TOSVersionInfo.dwMajorVersion/dwMinorVersion/dwBuildNumber }
  Win32MajorVersion: Integer = 0;
  Win32MinorVersion: Integer = 0;
  Win32BuildNumber: Integer = 0;

{ Win32 OS extra version info string -
  see TOSVersionInfo.szCSDVersion }

  Win32CSDVersion: string = '';

Marc
--------------------------------------------------------------------------
Marc Scheuner                            Berner Versicherungen, Dept. ISV
May the Source be With You               Laupenstrasse 27
marc.scheu...@berner.ch                  CH-3001 BERNE, Switzerland
--------------------------------------------------------------------------

Other Threads