如题。我现在编程只能辨别操作系统是Windows 2000或其他操作系统(Win95、Win98、Win98SE、WinXP),但无法区别Windows 2000是Server、Professional、Advanced Server中的哪一个。

解决方案 »

  1.   

    //这个
    function GetWindowsVersion: string;
    var
     // windows api structure
     VersionInfo: TOSVersionInfo;
    begin
    // get size of the structure
    VersionInfo.dwOSVersionInfoSize := SizeOf(VersionInfo);
    // populate the struct using api call
    GetVersionEx(VersionInfo);
    // platformid gets the core platform
    // major and minor versions also included.
    with VersionInfo do
    begin
     case dwPlatformid of
       0 : begin
          result := 'Windows 3.11';
         end;  // end 0   1 : begin
         case dwMinorVersion of
          0 : result := 'Windows 95';
          10: begin
            if ( szCSDVersion[ 1 ] = 'A' ) then
              Result :='Windows 98 SE'
            else
              Result := 'Windows 98';
            end; // end 10
          90 : result := 'Windows Millenium';
         else
          result := 'Unknown Version';
         end; // end case
        end; // end 1   2 : begin
         case dwMajorVersion of
          3 : result := 'Windows NT ' +
                    IntToStr(dwMajorVersion) + '.' +
                    IntToStr(dwMinorVersion);
          4 : result := 'Windows NT ' +
                    IntToStr(dwMajorVersion) + '.' +
                    IntToStr(dwMinorVersion);
          5 : begin
             case dwMinorVersion of
               0 : result := 'Windows 2000';
               1 : result := 'Windows xp';
             end; // end case
            end; // end 5
          else
            result := 'Unknown Version';
         end; // end case
         // service packs apply to the NT/2000 platform
         if szCSDVersion <> '' then
           result := result + ' Service pack: ' + szCSDVersion;
        end; // end 2
       else
        result := 'Unknown Platform';
     end; // end case
     // add build info.
     result := result + ', Build: ' +
          IntToStr(Loword(dwBuildNumber)) ;
    end; // end version info
    end; // GetWindowsVersion
      

  2.   

    转贴
    type
      TOSVersion = (osUnknown, os95, os95OSR2, os98, os98SE, osNT3, osNT4, os2K, osME,osXP);  Function  IsNT(var OS:string): boolean;//判断是否是NT系统
      Function  GetOS :TOSVersion;           //获得操作系统//获取操作系统
    function GetOS;
    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: begin
                 if OS.dwMinorVersion>=1 then
                   Result:=osXP
                 else
                   Result:=os2K;
               end;
          end;
        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;//判断是否时NT系统
    function IsNT(var OS:string): boolean;
    var
      OSVI :TOSVersion;
    begin
      OS:='不知道';
      OSVI:=GetOs;
      if OSVI=osNT3
        then OS:='Window NT3';
      if OSVI=OSNT4
        then OS:='Window NT4';
      if OSVI=os2K
        then OS:='Winodw 2000';
      if OSVI=os95
        then OS:='Window 95';
      if OSVI=os95OSR2
        then OS:='Window 97';
      if OSVI=os98
        then OS:='Winodw 98';
      if OSVI=os98SE
        then OS:='Winodw 98SE';
      if OSVI=osME
        then OS:='Winodw ME';
      Result:=GetOS in [osNT3,osNT4,os2K,osXP];
    end; 
      

  3.   

    注册表里有HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ProductOptions\ProductType
    ServerNT is Advance Server
    LaminNT is Server
    WinNT is Professional