怎样得到系统的类型 是 98 还是 2000(50分)

  • 主题发起人 主题发起人 f643208
  • 开始时间 开始时间
F

f643208

Unregistered / Unconfirmed
GUEST, unregistred user!
怎样得到系统的类型 是 98 还是 2000
 
有一个基本常量为WIN32PLATFORM
若为VER_PLATFORM_WIN32_NT即为2000或NT
你可以去查一下帮助
 
unit Unit1;

interface

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

type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

const strOsType: array[0..7] of string=('osUnknown','osWin95','osWin98','osWin98se','osWinme','osWinnt4','osWin2k','osWinxp');
type OSType=(osUnknown,osWin95,osWin98,osWin98se,osWinme,osWinnt4,osWin2k,osWinxp);

var
Form1: TForm1;

implementation

{$R *.DFM}

Function GetOSVersion : OSType;
Var
osVerInfo : TOSVersionInfo;
majorVer, minorVer : Integer;
Begin

//Result := osUnknown;
osVerInfo.dwOSVersionInfoSize := SizeOf( TOSVersionInfo );
If ( GetVersionEx( osVerInfo ) ) Then
Begin
majorVer := osVerInfo.dwMajorVersion;
minorVer := osVerInfo.dwMinorVersion;
Case ( osVerInfo.dwPlatformId ) Of
VER_PLATFORM_WIN32_NT : { Windows NT/2000 }
Begin
If ( majorVer <= 4 ) Then
Result := osWinnt4
Else
If ( ( majorVer = 5 ) And ( minorVer= 0 ) ) Then
Result := osWin2k
Else
If ( ( majorVer = 5) And ( minorVer = 1 ) ) Then
Result := osWinxp
Else
Result := OsUnknown;
End;
VER_PLATFORM_WIN32_WINDOWS : { Windows 9x/ME }
Begin

If ( ( majorVer = 4 ) And ( minorVer = 0 ) ) Then
Result := osWin95
Else If ( ( majorVer = 4 ) And ( minorVer = 10 ) ) Then
Begin
If ( osVerInfo.szCSDVersion[ 1 ] = 'A' ) Then
Result := osWin98se
Else
Result := osWin98;
End
Else If ( ( majorVer = 4) And ( minorVer = 90 ) ) Then
Result := OsWinME
Else
Result := OsUnknown;

End;
Else
Result := OsUnknown;
End; //end of case
End Else
Result := OsUnknown;

End;

procedure TForm1.Button1Click(Sender: TObject);
begin
ShowMessage(strOsType[integer(GetOSVersion)]);
end;

end.
 
const
OS_WINNT = 1; { WINDOWS NT}
OS_WIN32 = 0; { WINDOWS 95 OR 98}
OS_WINS = 2; { WIN32 OR WIN3.1}
OS_WINNT4 = 3; { WINNT 4 }
OS_WIN2k = 4; { Win2k }


function WinVer: Integer;
var
OSVerInfo: TOSVersionInfo;
begin
try
OSVerInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);
GetVersionEx(OSVerInfo);
result := OSVerInfo.dwMajorVersion;
case OSVerInfo.dwPlatformID of
VER_PLATFORM_WIN32s: Result := OS_WINS;
VER_PLATFORM_WIN32_WINDOWS: result := OS_WIN32;
VER_PLATFORM_WIN32_NT: begin
case OSVerInfo.dwMajorVersion of
1: result := OS_WINNT;
2: result := OS_WINNT;
3: result := OS_WINNT;
4: result := OS_WINNT4;
5: result := OS_WIN2k;
end;
end
else
result := OSVerInfo.dwPlatformID;
end;
except
result := -1;
end;
end;
 
case Win32Platform of
VER_PLATFORM_WIN32S:
message('您的WINDOWS版本是win32');
VER_PLATFORM_WIN32_WINDOWS:
message('您的WINDOWS版本是win98/me');
VER_PLATFORM_WIN32_NT:
message('您的WINDOWS版本是winnt/2000');
end;
 
接受答案了.
 
后退
顶部