delphi 判断系统是不是 win10_delphi判断windows-CSDN博客

type
  NET_API_STATUS = DWORD;
 
 
  _SERVER_INFO_101 = record
    sv101_platform_id: DWORD;
    sv101_name: LPWSTR;
    sv101_version_major: DWORD;
    sv101_version_minor: DWORD;
    sv101_type: DWORD;
    sv101_comment: LPWSTR;
  end;
  SERVER_INFO_101 = _SERVER_INFO_101;
  PSERVER_INFO_101 = ^SERVER_INFO_101;
  LPSERVER_INFO_101 = PSERVER_INFO_101;
 
 
const
  MAJOR_VERSION_MASK = $0F;
 
 
function NetServerGetInfo(servername: LPWSTR; level: DWORD; var bufptr): NET_API_STATUS; stdcall; external 'Netapi32.dll';
function NetApiBufferFree(Buffer: Pointer): NET_API_STATUS; stdcall; external 'Netapi32.dll';
 
type
  pfnRtlGetVersion = function(var RTL_OSVERSIONINFOEXW): LongInt; stdcall;
 
 
 
 
 
 
//////////实现/////////
 
function GetWindowsVersion: integer;
 
var
  Buffer: PSERVER_INFO_101;
  ver: RTL_OSVERSIONINFOEXW;
  RtlGetVersion: pfnRtlGetVersion;
begin
  Result := -1;
  Buffer := nil;
  // Win32MajorVersion and Win32MinorVersion are populated from GetVersionEx()...
 
 
  @RtlGetVersion := GetProcAddress(GetModuleHandle('ntdll.dll'), 'RtlGetVersion');
  if Assigned(RtlGetVersion) then
  begin
    ZeroMemory(@ver, SizeOf(ver));
    ver.dwOSVersionInfoSize := SizeOf(ver);
 
 
    if RtlGetVersion(ver) = 0 then
      Result := ver.dwMajorVersion; // shows 10.0
  end;
 
 
  if NetServerGetInfo(nil, 101, Buffer) = NO_ERROR then
  try
    result := Buffer.sv101_version_major and MAJOR_VERSION_MASK; // shows 10.0
  finally
    NetApiBufferFree(Buffer);
  end;
end;

--------------------------------

if GetWindowsVersion=10 then
//win10用自带的edge砸开
   ShellExecute(Handle, 'open', PChar('a.html'), nil, nil, SW_SHOW)
else if GetWindowsVersion=6 then
//win7已安装 chrome
   ShellExecute(Handle, nil, PChar('chrome.exe')
      , PChar('file:///'+ExtractFilePath (ParamStr (0))+ 'a.html')
      , nil, SW_SHOWNORMAL);

   ListBox_keyWords.Visible:= False;
end;