GetCPUID for lazarus(windows),兼容32/64位,直接上代码:
unit GetCPUIDUnit; {$mode objfpc}{$H+} {$ASMMODE intel} interface uses Classes, SysUtils; function GetCPUID:string; implementation function GetCPUID:string; var _ecx,_edx,_eaX,_ebx:LongWord; begin //执行CPUID指令,EAX=1/RAX=1 asm {$IFDEF CPUX64} MOV RAX,1 PUSH RCX PUSH RBX PUSH RDX {$ELSE} MOV EAX,1 PUSH ECX PUSH EBX PUSH EDX {$ENDIF} cpuid //执行cPUID指令 mOV _eaX,eaX mOV _ebx,ebx mOV _ecX,ecX mov _edx,edx {$IFDEF CPUX64} POP RDX POP RBX POP RCX {$ELSE} POP EDX POP EBX POP ECX {$ENDIF} end; //将寄存器值转换为十六进制字符串 Result := IntToHex(_eax,8)+IntToHex(_ecx,8)+IntToHex(_edx,8); end; end.
标签:GetCPUID,windows,mOV,POP,lazarus,PUSH,edx,ebx From: https://www.cnblogs.com/qiufeng2014/p/18655207