//This unit can be used to detect the cpu model.
unit CpuId; interface uses Windows, Mmsystem, Sysutils, Math, Dialogs; type TCpuRec=record Name:string[128]; Vendor:string[12]; Frequency:word; Family:integer; Model:integer; Stepping:integer; L1DCache:word; L1ICache:word; L2Cache:word; end; TCpuType = (cpu8086, cpu286, cpu386, cpu486, cpuPentium); TCpuData=object function GetCPUIDSupport:Boolean; function GetVendorString:string; function GetCPUFrequency:word; procedure GetFMS(var Family,Model,Stepping:byte); function GetMaxCpuId:dword; function CheckFPU:Boolean; function CheckTSC:Boolean; function CheckMSR:Boolean; function CheckMPS:Boolean; function GetNoCpus:cardinal; function CheckPN:Boolean; function CheckCMPXCHG8B:Boolean; function CheckCMOVe:Boolean; function CheckSelfSnoop:Boolean; function CheckDebugTraceStore:Boolean; function CheckFXSAVEFXRSTOR:Boolean; function CheckMMX:Boolean; function CheckMMXplus:Boolean; function CheckSSE:Boolean; function CheckSSE2:Boolean; function CheckAMD3DNow:Boolean; function CheckAMD3DNowPlus:Boolean; function GetMaxExtendedFunctions:dword; procedure GetExtendedFMS(var Family,Model,Stepping:byte); function GetExtendedCpuName:string; function GetExtendedL1DCache:word; function GetExtendedL1ICache:word; function GetExtendedL2Cache:word;
function CheckCeleron:Boolean; function CheckPentiumIII:Boolean; function CheckXeon:Boolean; function CheckPentium4:Boolean; function CheckIthanium:Boolean; function IntelP5N:string; function IntelP6N:string; function AMDK5N:string; function Cyrix686N:string; function GenericCpuN:string; function P5CacheL1DI:word; function P6CacheL1DI:word; function P6CacheL2:word;
pushfd pop eax mov ebx,eax xor eax,$00200000 push eax popfd pushfd pop eax push ebx popfd xor eax,ebx mov TempDetect,eax
pop edx pop ecx pop ebx pop eax popfd popf end; GetCPUIDSupport:=(TempDetect=$00200000); end; function TCpuData.GetVendorString:string; var s1,s2,s3:array[0..3] of char; TempVendor:string; i:integer; begin asm push eax push ebx push ecx push edx mov eax,0 db $0F,$A2 /// cpuid mov s1,ebx mov s2,edx mov s3,ecx pop edx pop ecx pop ebx pop eax end; TempVendor:=''''''''; for i:=0 to 3 do TempVendor:=TempVendor+s1[i]; for i:=0 to 3 do TempVendor:=TempVendor+s2[i]; for i:=0 to 3 do TempVendor:=TempVendor+s3[i]; GetVendorString:=TempVendor; end; function TCpuData.GetCPUFrequency:word; const timePeriod= 1000; var HighFreq,TestFreq,Count1,Count2:int64; TimeStart:integer; TimeStop:integer; ElapsedTime:dword; StartTicks:dword; EndTicks:dword; TotalTicks:dword; begin StartTicks:=0; EndTicks:=0; if QueryPerformanceFrequency(HighFreq) then begin
TestFreq:=HighFreq div 100;
QueryPerformanceCounter(Count1); repeat QueryPerformanceCounter(Count2); until Count1<>Count2;