转至繁体中文版     | 网站首页 | 图文教程 | 资源下载 | 站长博客 | 图片素材 | 武汉seo | 武汉网站优化 | 
最新公告:     敏韬网|教学资源学习资料永久免费分享站!  [mintao  2008年9月2日]        
您现在的位置: 学习笔记 >> 图文教程 >> 软件开发 >> Delphi程序 >> 正文
get CPU id (很全的)         ★★★★

get CPU id (很全的)

作者:闵涛 文章来源:闵涛的学习笔记 点击数:4888 更新时间:2009/4/23 18:39:23
//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;

      function AuthenticAMD:TCpuRec;

      function GenuineIntel:TCpuRec;
      function CyrixInstead:TCpuRec;
      function GenericCPU:TCpuRec;
     end;
const
Intel486:array[0..8] of string=
(''''Intel 486 DX'''',
  ''''Intel 486 DX'''',
  ''''Intel 486 SX'''',
  ''''Intel 486 DX2'''',
  ''''Intel 486 SL'''',
  ''''Intel 486 SX2'''',
  ''''Intel 486 DX2'''',
  ''''Intel 486 DX4'''',
  ''''Intel 486 DX4'''');
UMC486:array[0..1] of string=
(''''UMC U5D'''',
  ''''UMC U5S'''');
AMD486:array[0..5] of string=
(''''AMD 486 DX2'''',
  ''''AMD 486 DX2'''',
  ''''AMD 486 DX4'''',
  ''''AMD 486 DX4'''',
  ''''AMD 5x86'''',
  ''''AMD 5x86'''');
IntelP5:array[0..6] of string=
(''''Intel Pentium P5 A-Step'''',
  ''''Intel Pentium P5'''',
  ''''Intel Pentium P54C'''',
  ''''Intel Pentium P24T Overdrive'''',
  ''''Intel Pentium MMX P55C'''',
  ''''Intel Pentium P54C'''',
  ''''Intel Pentium MMX P55C'''');
  NexGenNx586=''''NexGen Nx586'''';
  Cyrix4x86=''''VIA Cyrix 4x86'''';
  Cyrix5x86=''''VIA Cyrix 5x86'''';
  CyrixMediaGX=''''VIA Cyrix Media GX'''';
  CyrixM1=''''VIA Cyrix 6x86'''';
  CyrixM2=''''VIA Cyrix 6x86MX'''';
  CyrixIII=''''VIA Cyrix III'''';
  AMDK5:array[0..3] of string=
  (''''AMD SSA5 (PR75/PR90/PR100)'''',
   ''''AMD 5k86 (PR120/PR133)'''',
   ''''AMD 5k86 (PR166)'''',
   ''''AMD 5k86 (PR200)'''');
  AMDK6:array[0..4] of string=
  (''''AMD K6 (166~233)'''',
   ''''AMD K6 (266~300)'''',
   ''''AMD K6-2'''',
   ''''AMD K6-III'''',
   ''''AMD K6-2+ or K6-III+'''');
   Centaur:array[0..2] of string=
   (''''Centaur C6'''',
    ''''Centaur C2'''',
    ''''Centaur C3'''');
   Rise:array[0..1] of string=
   (''''Rise mP6'''',
    ''''Rise mP6'''');
   IntelP6:array[0..7] of string=
   (''''Intel Pentium Pro A-Step'''',
    ''''Intel Pentium Pro'''',
    ''''Intel Pentium II'''',
    ''''Intel Pentium II'''',
    ''''Intel Pentium II'''',
    ''''Intel Pentium III'''',
    ''''Intel Pentium III'''',
    ''''Intel Pentium III'''');
   AMDK7:array[0..3] of string=
    (''''AMD Athlon(tm) Processor'''',
     ''''AMD Athlon(tm) Processor'''',
     ''''AMD Duron(tm) Processor'''',
     ''''AMD Thunderbird Processor'''');
   IntelP4=''''Intel Pentium 4'''';
var CpuData:TCpuData;
implementation
function TCpuData.GetCPUIDSupport:Boolean;
var TempDetect:dword;
begin
asm
  pushf
  pushfd
  push eax
  push ebx
  push ecx
  push edx

  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;

    asm
      push ebx
      xor eax,eax
      xor ebx,ebx
      xor ecx,ecx
      xor edx,edx
      d

[1] [2] [3] [4] [5] [6] [7]  下一页


[Web开发]GridView根据值的变化改变行列样式  [Web开发]asp.net中DataGrid中实现CheckBox列
[Web开发]DataGrid或DataView进行求合  [Web开发]Grid或GridView分页数据不足,如何显示空行
[Web开发]设置GridView控件表头背景图片(前台设置)  [Web开发]设置GridView控件表头背景图片
[Web开发]Net读取(上传的)Excel内容显示到GridView示例源代…  [Web开发]长篇大论—图文解说DridView、DataList、DetailsV…
[Web开发]一大堆常用的超强的正则表达式及RegularExpressio…  [Web开发]ASP.NET2.0中Gridview中数据控件的操作技巧下篇
教程录入:mintao    责任编辑:mintao 
  • 上一篇教程:

  • 下一篇教程:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
      注:本站部分文章源于互联网,版权归原作者所有!如有侵权,请原作者与本站联系,本站将立即删除! 本站文章除特别注明外均可转载,但需注明出处! [MinTao学以致用网]
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)

    同类栏目
    · C语言系列  · VB.NET程序
    · JAVA开发  · Delphi程序
    · 脚本语言
    更多内容
    热门推荐 更多内容
  • 没有教程
  • 赞助链接
    更多内容
    闵涛博文 更多关于武汉SEO的内容
    500 - 内部服务器错误。

    500 - 内部服务器错误。

    您查找的资源存在问题,因而无法显示。

    | 设为首页 |加入收藏 | 联系站长 | 友情链接 | 版权申明 | 广告服务
    MinTao学以致用网

    Copyright @ 2007-2012 敏韬网(敏而好学,文韬武略--MinTao.Net)(学习笔记) Inc All Rights Reserved.
    闵涛 投放广告、内容合作请Q我! E_mail:admin@mintao.net(欢迎提供学习资源)

    站长:MinTao ICP备案号:鄂ICP备11006601号-18

    闵涛站盟:医药大全-武穴网A打造BCD……
    咸宁网络警察报警平台