用GetVersionEx获取版本信息, Windows Vista与Windows Server 2008返回都是 6.0
要怎么区分这两个操作系统?

解决方案 »

  1.   


    {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;Returns true if the operating system is Windows Vista or later and false if not. 
    function IsVista: Boolean;
    var
      PFunction: Pointer; // pointer to GetProductInfo function if exists
    begin
      // Try to load GetProductInfo from Kernel32: present if Vista
      PFunction := Windows.GetProcAddress(
        Windows.GetModuleHandle('kernel32.dll'), 'GetProductInfo'
      );
      Result := Assigned(PFunction);
    end;
      

  2.   

    谢谢!注册表里面找到了HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersionProductName