赞
踩
转载请保留本文链接地址:http://blog.csdn.net/sushengmiyan/article/details/8545673
- {-----------------------------------------------------------------------------
- 作者:sushengmiyan 2013.01.26
- 备注:
- 功能:硬件信息获取单元
- -----------------------------------------------------------------------------}
-
- unit ApplicationHardWareInfo;
-
- interface
- uses
- Windows, SysUtils, Classes, Registry, Nb30, WinSock;
-
- type
- TCPUID = array[1..4] of Longint;
- function GetCPUID: TCPUID; assembler; register;
- type
-
- //CPUID信息类
- TCPUIDInfo = class
- private
- FCPUID: TCPUID;
- FCPUIDStr: string;
- procedure SetCPU(AHandle: THandle; CpuNo: Integer);
- function CPUIDTostr(ACPUID: TCPUID): string;
- function GetComputerBasicFrequency: string;
- function GetCPUType: string;
- public
- function GetCPUIDstr: string;
- property CPUFrequency: string read GetComputerBasicFrequency;
- property ProcessorType: string read GetCPUType;
- constructor Create;
- end;
-
- //mac地址信息类
- TMacAdressInfo = class
- private
- FMacAdress: string;
- function GetMacPhysicalAddress(Alana: Integer = 0): string;
- function GetMacAddress: string;
- public
- property MacAdrress: string read GetMacAddress;
- constructor Create;
- end;
-
- //用户信息类
- TPCUserInfo = class
- private
- function GetUserName: string;
- function GetHostIP: string;
- function GetWindowsVertion: string;
- public
- property 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;
- asm
- PUSH EBX {Save affected register}
- PUSH EDI
- MOV EDI,EAX {@Resukt}
- MOV EAX,1
- DW $A20F {CPUID Command}
- STOSD {CPUID[1]}
- MOV EAX,EBX
- STOSD {CPUID[2]}
- MOV EAX,ECX
- STOSD {CPUID[3]}
- MOV EAX,EDX
- STOSD {CPUID[4]}
- POP EDI {Restore registers}
- POP EBX
- end;
-
- {----------------------------------------------------------------------------\-
- 作者:sushengmiyan 2013.01.26
- 参数:ACPUID: TCPUID
- 返回:string
- 功能:将十六进制的CPUID转换为字符串
- \-----------------------------------------------------------------------------}
-
- function TCPUIDInfo.CPUIDTostr(ACPUID: TCPUID): string;
- begin
- Result := '';
- Result := IntToHex(ACPUID[1] , 8) + IntToHex(ACPUID[2] , 8) + I

Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。