本文主要是介绍获取硬件信息的delphi源码(CPUID、操作系统、Mac物理地址、计算机名称、IP地址、用户名),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
转载请保留本文链接地址:http://blog.csdn.net/sushengmiyan/article/details/8545673
{-----------------------------------------------------------------------------
作者:sushengmiyan 2013.01.26
备注:
功能:硬件信息获取单元
-----------------------------------------------------------------------------}unit ApplicationHardWareInfo;interface
usesWindows, SysUtils, Classes, Registry, Nb30, WinSock;typeTCPUID = array[1..4] of Longint;function GetCPUID: TCPUID; assembler; register;
type//CPUID信息类TCPUIDInfo = classprivateFCPUID: TCPUID;FCPUIDStr: string;procedure SetCPU(AHandle: THandle; CpuNo: Integer);function CPUIDTostr(ACPUID: TCPUID): string;function GetComputerBasicFrequency: string;function GetCPUType: string;publicfunction GetCPUIDstr: string;property CPUFrequency: string read GetComputerBasicFrequency;property ProcessorType: string read GetCPUType;constructor Create;end;//mac地址信息类TMacAdressInfo = classprivateFMacAdress: string;function GetMacPhysicalAddress(Alana: Integer = 0): string;function GetMacAddress: string;publicproperty MacAdrress: string read GetMacAddress;constructor Create;end;//用户信息类TPCUserInfo = classprivatefunction GetUserName: string;function GetHostIP: string;function GetWindowsVertion: string;publicproperty UserName: string read GetUserName;property HostIP: string read GetHostIP;property WindowsVertion: string read GetWindowsVertion;constructor Create;end;implementation{ TCPUIDInfo }
{----------------------------------------------------------------------------\-
作者:sushengmiyan 2013.01.26
参数:None
返回:TCPUID
功能:汇编方式获取CPUID
\-----------------------------------------------------------------------------}function GetCPUID: TCPUID;
asmPUSH EBX {Save affected register}PUSH EDIMOV EDI,EAX {@Resukt}MOV EAX,1DW $A20F {CPUID Command}STOSD {CPUID[1]}MOV EAX,EBXSTOSD {CPUID[2]}MOV EAX,ECXSTOSD {CPUID[3]}MOV EAX,EDXSTOSD {CPUID[4]}POP EDI {Restore registers}POP EBX
end;{----------------------------------------------------------------------------\-
作者:sushengmiyan 2013.01.26
参数:ACPUID: TCPUID
返回:string
功能:将十六进制的CPUID转换为字符串
\-----------------------------------------------------------------------------}function TCPUIDInfo.CPUIDTostr(ACPUID: TCPUID): string;
beginResult := '';Result := IntToHex(ACPUID[1] , 8) + IntToHex(ACPUID[2] , 8) + I
这篇关于获取硬件信息的delphi源码(CPUID、操作系统、Mac物理地址、计算机名称、IP地址、用户名)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!