API GetVersionEx in MSDN !!!

解决方案 »

  1.   

    unit SystemInfo;interfaceuses
      Windows, Messages, SysUtils, Dialogs, Registry;type
       SystemInfoRecord = record
         // Os
         Version:         string;
         Plattform:       string;
         // Processor
         ProcOemId:       word;
         ProcNum:         word;
         ProcType:        string;
         ProcVers:        string;
         // Memory
         MemTotal:        Dword;
         MemAvailable:    Dword;
         MemUsage:        Dword;
         SwapFileSetting: Dword;
         SwapFileSize:    Dword;
         SwapFileUsage:   Dword;
         // Registration
         UserName:        string;
         CompanyName:     string;
         SerialNo:        string;
         // Language ID's
         SystemDefLangID: string;
         UserDefLangID:   string;
       end;var
       SystemInfoRec: SystemInfoRecord;
       PlattformId:   Dword;           // used in other routines
       CurRegKey:     PChar;
       procedure GetAllSystemInfo;
    implementation
    {-------------------------------------------------------------------------------
    }
    function Plat(Pl: DWORD): string;
    begin
      case Pl of
        VER_PLATFORM_WIN32s:        result := 'Win32s on Windows 3.1x';
        VER_PLATFORM_WIN32_WINDOWS: result := 'Windows 95/98';
        VER_PLATFORM_WIN32_NT:      result := 'Windows NT';
        else                        result := 'Unknow';
      end;
    end;
    {-------------------------------------------------------------------------------
    }
    procedure GetAllSystemInfo;
    var OS: TOSVersionInfo;
        SI: TSystemInfo;
        MS: TMemoryStatus;
    begin
      with SystemInfoRec do begin    // get win plattform & version
        with OS do begin
          dwOSVersionInfoSize := SizeOf(TOSVersionInfo);
          if GetVersionEx(OS) then begin
            Version := Format('%d.%d (%d.%s)',[dwMajorVersion, dwMinorVersion,
              (dwBuildNumber and $FFFF), szCSDVersion]);
            Plattform   := Plat(dwPlatformId);
            PlattformId := dwPlatformId;
          end;
        end; // with OS    // get processor type & info
        with SI do begin
          GetSystemInfo(SI);
          ProcOemId := dwOemId;
          ProcNum   := dwNumberOfProcessors;      case dwProcessorType of
            386  : ProcType := ' 386';
            486  : ProcType := ' 486';
            586  : ProcType := ' Pentium';
            4000 : ProcType := ' MIPS Risc 4000';
            21064: ProcType := ' ALPHA';
          end;
          ProcVers := Format('Level %d  Rev. %d.%d',
            [wProcessorLevel, hi(wProcessorRevision), lo(wProcessorRevision)]);
        end; // with SI    // Get memory status & dim
        with MS do begin
          dwLength := sizeof(TMemoryStatus);
          GlobalMemoryStatus(MS);      MemTotal        := dwTotalPhys;
          MemAvailable    := dwAvailPhys;
          MemUsage        := 100-trunc(dwAvailPhys/dwTotalPhys*100);
          SwapFileSetting := dwTotalPageFile;
          SwapFileSize    := dwTotalPageFile-dwAvailPageFile;
          SwapFileUsage   := 100-trunc(dwAvailPageFile/dwTotalPageFile*100);
        end; // with MS    // get registration info
        case PlattformId of
          VER_PLATFORM_WIN32_WINDOWS :
            CurRegKey := '\SOFTWARE\Microsoft\Windows\CurrentVersion';
          VER_PLATFORM_WIN32_NT      :
            CurRegKey := '\SOFTWARE\Microsoft\Windows NT\CurrentVersion';
          else  CurRegKey := nil;
        end;
        with TRegistry.Create do
        try
          RootKey := HKEY_LOCAL_MACHINE;
          if OpenKey(CurRegKey, False) then begin
            UserName := ReadString('RegisteredOwner');
            CompanyName := ReadString('RegisteredOrganization');
            SerialNo :=  ReadString('ProductID');
          end; // if
        finally
          Free;
        end; // try
        SystemDefLangID := Format('$%.4x',[GetSystemDefaultLangID]);
        UserDefLangID   := Format('$%.4x',[GetUserDefaultLangID]);
      end; // SystemInfoRec
    end;
      

  2.   

    那系统是win2000怎么办?  
    还有侦测处理器信息,怎么办?