Mega Code Archive

 
Categories / Delphi / Examples
 

Retrieving the active version of windows or dos

Call the GetVersion Windows API function to return version information for Windows and DOS. The function returns a LongInt which contains this information: Byte #1 - Windows Version (Integer part) Byte #2 - Windows Version (Fractional part) Byte #3 - DOS Version (Fractional part) Byte #4 - DOS Version (Integer part) To display the versions in a Delphi form, create two Labels and add the following OnCreate event-handler: procedure TForm1.FormCreate(Sender: TObject); var Version : LongInt; begin Version := GetVersion; Label1.Caption := 'Windows ' + IntToStr(LoByte(LoWord(Version))) + '.' + IntToStr(HiByte(LoWord(Version))); Label2.Caption := 'DOS ' + IntToStr(HiByte(HiWord(Version))) + '.' + IntToStr(LoByte(HiWord(Version))); end;