这里主要学习这个类:
OSVERSIONINFO
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
osinfo:OSVERSIONINFO;
begin
osinfo.dwOSVersionInfoSize:=sizeof(OSVERSIONINFO);
//通过API函数获得版本信息
GetVersionEx(osinfo);
//在MEMO中显示信息
Memo1.Lines.Append('当前操作系统的主版本号为:'
+IntToStr(osinfo.dwMajorVersion));
Memo1.Lines.Append('当前操作系统的次版本号为:'
+IntToStr(osinfo.dwMinorVersion));
Memo1.Lines.Append('当前操作系统的构件数为:'
+IntToStr(osinfo.dwBuildNumber));
Memo1.Lines.Append('当前操作系统的平台为:'
+IntToStr(osinfo.dwPlatformId));
Memo1.Lines.Append('当前操作系统的补丁号为:'
+osinfo.szCSDVersion);
end;
end.