2009. június 9., kedd

How to determine the CPU type


Problem/Question/Abstract:

How can I check what type my CPU is? E.g. Pentium (PI, PII, PIII or PIV), AMD (K6, K7, Athlon, ThunderBird), IBM, Cyrix or other CPU's.

Answer:

uses
  Windows;

type
  TProcessor = (NON_INTEL, I_386, I_486, I_PENTIUM, I_PENTIUMPRO,
    I_CELERON, I_PENTIUM2, I_PENTIUM3, I_PENTIUM4);

  {This is for Intel - I haven't tried for AMD etc.}

function GetProcessor: TProcessor;
var
  SI: SYSTEM_INFO;
begin
  Result := NON_INTEL;
  GetSystemInfo(SI);
  if (SI.wProcessorArchitecture = 0) then
  begin
    case (SI.wProcessorLevel and 15) of
      3:
        Result := I_386;
      4:
        Result := I_486;
      5:
        Result := I_PENTIUM;
      6:
        case hi(SI.wProcessorRevision) of
          1: Result := I_PENTIUMPRO;
          3, 5: Result := I_PENTIUM2;
          6: Result := I_CELERON;
          7, 8, 10, 11: Result := I_PENTIUM3;
        end;
      15:
        Result := I_PENTIUM4;
    end;
  end;
end;

Nincsenek megjegyzések:

Megjegyzés küldése