用Delphi编程得到OS的类型_Delphi

  • 内容
  • 评论
  • 相关

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, CommDlg;

type
  TForm1 = class(TForm)

http://www.gaodaima.com/65685.htmlDelphi编程得到OS的类型_Delphi

    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
type
  TOSVersion = (osUnknown, os95, os95OSR2, os98, os98SE, osNT3, osNT4, os2K, osME, osXP);

var
  Form1: TForm1;

implementation

{$R *.DFM}

function GetOS :TOSVersion;
var
  OS :TOSVersionInfo;
begin
  ZeroMemory(@OS,SizeOf(OS));
  OS.dwOSVersionInfoSize:=SizeOf(OS);
  GetVersionEx(OS);
  Result:=osUnknown;
  if OS.dwPlatformId=VER_PLATFORM_WIN32_NT then begin
    case OS.dwMajorVersion of
      3: Result:=osNT3;
      4: Result:=osNT4;
      5: Result:=os2K;
    end;
    if (OS.dwMajorVersion=5) and (OS.dwMinorVersion=1) then
      Result:=osXP;
  end else begin
    if (OS.dwMajorVersion=4) and (OS.dwMinorVersion=0) then begin
      Result:=os95;
      if (Trim(OS.szCSDVersion)='B') then
        Result:=os95OSR2;
    end else
      if (OS.dwMajorVersion=4) and (OS.dwMinorVersion=10) then begin
        Result:=os98;
        if (Trim(OS.szCSDVersion)='A') then
          Result:=os98SE;
      end else
        if (OS.dwMajorVersion=4) and (OS.dwMinorVersion=90) then
          Result:=osME;
  end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
os:TosVersion;
osVersion:string;
begin
  os:=Getos;
      case OS of
    os95, os95OSR2: OSVersion:='Windows 95';
    os98: OSVersion:='Windows 98';
    os98SE: OSVersion:='Windows 98 第二版';
    osME: OSVersion:='Windows Millenium Edition';
    osNT3, osNT4: OSVersion:='Windows NT';
    os2K: OSVersion:='Windows 2000';
    osXP: OSVersion:='Windows XP';
  end;
   showmessage(osversion);
end;

end.

欢迎大家阅读《用Delphi编程得到OS的类型_Delphi》,跪求各位点评,若觉得好的话请收藏本文,by 搞代码

原创文章,转载请注明: 转载自搞代码

本文链接地址: 用Delphi编程得到OS的类型_Delphi

微信支付二维码

微信 赏一包辣条吧~

支付宝支付二维码

支付宝 赏一听可乐吧~

评论

0条评论

发表评论

电子邮件地址不会被公开。 必填项已用*标注