几个判断OS版本的函数

IsWin9x
Returns true if the operating system is on the Windows 9x platform or false if not.
function IsWin9x: Boolean;
begin
  Result := SysUtils.Win32Platform = Windows.VER_PLATFORM_WIN32_WINDOWS;
end;
Kind of Snippet: Routine
Required units: SysUtils, Windows.
Required snippets: None.
Supported Compilers:
 D2  D3  D4  D5  D6  D7 D2005
(Win32)
D2006
(Win32)
D2007D2009
(Win32)
D2010
(Win32)
Free
Pascal
Green LEDGreen LEDGreen LEDGreen LEDGreen LEDGreen LEDGreen LEDGreen LEDGreen LEDGreen LEDGreen LEDGreen LED
Windows 95, 98 and Me are all on the Windows 9x platform.
IsWinNT
Returns true if the operating system is on the Windows NT platform or false if not.
function IsWinNT: Boolean;
begin
  Result := (SysUtils.Win32Platform = Windows.VER_PLATFORM_WIN32_NT);
end;
Kind of Snippet: Routine
Required units: SysUtils, Windows.
Required snippets: None.
Supported Compilers:
 D2  D3  D4  D5  D6  D7 D2005
(Win32)
D2006
(Win32)
D2007D2009
(Win32)
D2010
(Win32)
Free
Pascal
Green LEDGreen LEDGreen LEDGreen LEDGreen LEDGreen LEDGreen LEDGreen LEDGreen LEDGreen LEDGreen LEDGreen LED
Windows NT, 2000, XP, Server 2003, Vista, Server 2008 and Windows 7 are all on the NT Platform.
IsWow64
Returns true if the current process is executing as a 32 bit process under WOW64 on 64 bit Windows.
function IsWow64: Boolean;
type
  TIsWow64Process = function( // Type of IsWow64Process API fn
    Handle: Windows.THandle; var Res: Windows.BOOL
  ): Windows.BOOL; stdcall;
var
  IsWow64Result: Windows.BOOL;      // Result from IsWow64Process
  IsWow64Process: TIsWow64Process;  // IsWow64Process fn reference
begin
  // Try to load required function from kernel32
  IsWow64Process := Windows.GetProcAddress(
    Windows.GetModuleHandle('kernel32.dll'), 'IsWow64Process'
  );
  if Assigned(IsWow64Process) then
  begin
    // Function is implemented: call it
    if not IsWow64Process(
      Windows.GetCurrentProcess, IsWow64Result
    ) then
      raise SysUtils.Exception.Create('IsWow64: bad process handle');
    // Return result of function
    Result := IsWow64Result;
  end
  else
    // Function not implemented: can't be running on Wow64
    Result := False;
end;
Kind of Snippet: Routine
Required units: SysUtils, Windows.
Required snippets: None.
Supported Compilers:
 D2  D3  D4  D5  D6  D7 D2005
(Win32)
D2006
(Win32)
D2007D2009
(Win32)
D2010
(Win32)
Free
Pascal
Green LEDGreen LEDGreen LEDGreen LEDGreen LEDGreen LEDGreen LEDGreen LEDGreen LEDGreen LEDGreen LEDGreen LED
IsTabletOS
Returns true if the operating system is a Windows Tablet edition or false if not.
function IsTabletOS: Boolean;
const
  SM_TABLETPC = 86; // metrics flag not defined in Windows unit	
begin
  Result := Windows.GetSystemMetrics(SM_TABLETPC) <> 0;
end;
Kind of Snippet: Routine
Required units: Windows.
Required snippets: None.
Supported Compilers:
 D2  D3  D4  D5  D6  D7 D2005
(Win32)
D2006
(Win32)
D2007D2009
(Win32)
D2010
(Win32)
Free
Pascal
Green LEDGreen LEDGreen LEDGreen LEDGreen LEDGreen LEDGreen LEDGreen LEDGreen LEDGreen LEDGreen LEDGreen LED
IsMediaCenterOS
Returns true if the operating system includes Windows Media Center or false if not.
function IsMediaCenterOS: Boolean;
const
  SM_MEDIACENTER = 87; // metrics flag not defined in Windows unit	
begin
  Result := Windows.GetSystemMetrics(SM_MEDIACENTER) <> 0;
end;
Kind of Snippet: Routine
Required units: Windows.
Required snippets: None.
Supported Compilers:
 D2  D3  D4  D5  D6  D7 D2005
(Win32)
D2006
(Win32)
D2007D2009
(Win32)
D2010
(Win32)
Free
Pascal
Green LEDGreen LEDGreen LEDGreen LEDGreen LEDGreen LEDGreen LEDGreen LEDGreen LEDGreen LEDGreen LEDGreen LED
IsWindows7
Returns true if the operating system is Windows 7 (or Windows Server 2008 R2) or later and false if not.
function IsWindows7: Boolean;
var
  PFunction: Pointer; // points to PowerCreateRequest function if exists
begin
  // Try to load PowerCreateRequest from Kernel32:
  // present if Windows 7 or Server 2008 R2
  PFunction := Windows.GetProcAddress(
    Windows.GetModuleHandle('kernel32.dll'), 'PowerCreateRequest'
  );
  Result := Assigned(PFunction);
end;
Kind of Snippet: Routine
Required units: Windows.
Required snippets: None.
Supported Compilers:
 D2  D3  D4  D5  D6  D7 D2005
(Win32)
D2006
(Win32)
D2007D2009
(Win32)
D2010
(Win32)
Free
Pascal
Green LEDGreen LEDGreen LEDGreen LEDGreen LEDGreen LEDGreen LEDGreen LEDGreen LEDGreen LEDGreen LEDGreen LED
Returns true even if the application has defined a Windows Vista (or other) compatibility mode.

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值