标签:
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
unit GetSystemVersion;
interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.Buttons; type TMainFrm = class(TForm) edt1: TEdit; lbl1: TLabel; btn1: TBitBtn; procedure btn1Click(Sender: TObject); private { Private declarations } public { Public declarations } function GetWindowsVersionString: AnsiString; function GetWindowsVersion: String; end; var MainFrm: TMainFrm; implementation {$R *.dfm} function TMainFrm.GetWindowsVersionString : AnsiString; var VI: TOSVersionInfoA; begin VI.dwOSVersionInfoSize := SizeOf(TOSVersioninfoA); if GetVersionExA(VI) then with VI do Result := Trim ( Format( ‘%d.%d build %d %s‘, [dwMajorVersion, dwMinorVersion,dwBuildNumber,szCSDVersion] ) ) else Result:= ‘‘; end; procedure TMainFrm.btn1Click(Sender: TObject); begin edt1.Text := GetWindowsVersion; end; function TMainFrm.GetWindowsVersion : String; var AWin32Version : Extended; OS: string; begin OS:= ‘Windows ‘; AWin32Version := StrToFloat(Format(‘%d.%d‘,[Win32MajorVersion, Win32MinorVersion])); if Win32Platform = VER_PLATFORM_WIN32s then Result := OS + ‘32‘ else if Win32Platform = VER_PLATFORM_WIN32_WINDOWS then begin if AWin32Version = 4.0 then Result := OS + ‘95‘ else if AWin32Version = 4.1 then Result := OS + ‘98‘ else if AWin32Version = 4.9 then Result := OS + ‘Me‘ else Result := OS + ‘9X‘ end else if Win32Platform = VER_PLATFORM_WIN32_NT then begin if AWin32Version = 3.51 then Result := OS + ‘NT 3.51‘ else if AWin32Version = 4.0 then Result := OS + ‘NT 4.0‘ else if AWin32Version = 5.0 then Result :=OS + ‘2000‘ else if AWin32Version = 5.1 then Result := OS + ‘XP‘ else if AWin32Version = 5.2 then Result := OS + ‘2003‘ else if AWin32Version = 6.0 then Result:= OS +‘Vista‘ else if AWin32Version = 6.1 then Result := OS + ‘7‘ else if AWin32Version = 6.2 then Result := OS + ‘8‘ else Result := OS + ‘Other NT Kernal Windows‘; end else Result := OS; end; end. |
标签:
原文地址:http://www.cnblogs.com/kivin/p/4646943.html