好像获取CPU 信息 有重复
获取硬件序列号 好像可以修改
获取网卡信息 现在大多数的电脑都是2块网卡以上
好像很麻烦不知道 获取什么比较好
请大家帮忙 谢谢
获取硬件序列号 好像可以修改
获取网卡信息 现在大多数的电脑都是2块网卡以上
好像很麻烦不知道 获取什么比较好
请大家帮忙 谢谢
解决方案 »
- 我想对注册表中某一项的某个键值,并赋值给某个变量,该如何写代码?
- dbgrid
- 请叫各位,这条SQL语句哪错了啊!!在线等待,马上揭帖,分不够在加!!!!
- 写了一个线程,但在调用的时候出现这样的错误:Access voilation at address 004c3588 in Module'**.exe'.read of address 00000084
- “Operation must be performed on the current session.”是什么意思啊?它还是出现了这个提示错误!
- 怎样弹出“查找打印机”的对话框
- 急急急!!我想在前台用一个ADOStoredProc1在不同时间连接后台多个存储过程,在前台应怎么动态设置Paramerters??
- 在query中的查询问题(like)查询!
- 怎样用delphi7.0开发跨平台应用,且实现三层结构?
- 自己用 delphixe7_fmx 做的仿QQ界面
- 看这段代码
- 这是什么?怎么得到
重复就表示是对的呀.
如果出现不同的CPU ID,多半是因为双核的原因.
我是CPU+硬盘+序列号+时间(这个时间包含注册时间和到期时间)
然后用加密算法变一下。移动一位。
硬件的信息,可以取CPU、硬盘、BIOS等,之间组合构成特定的代码。
叫CnHardWareInfo;*****************************************************************************}
{ CnPack For Delphi/C++Builder }
{ 中国人自己的开放源码第三方开发包 }
{ (C)Copyright 2001-2008 CnPack 开发组 }
{ ------------------------------------ }
{ }
{ 本开发包是开源的自由软件,您可以遵照 CnPack 的发布协议来修 }
{ 改和重新发布这一程序。 }
{ }
{ 发布这一开发包的目的是希望它有用,但没有任何担保。甚至没有 }
{ 适合特定目的而隐含的担保。更详细的情况请参阅 CnPack 发布协议。 }
{ }
{ 您应该已经和开发包一起收到一份 CnPack 发布协议的副本。如果 }
{ 还没有,可访问我们的网站: }
{ }
{ 网站地址:http://www.cnpack.org }
{ 电子邮件:[email protected] }
{ }
{******************************************************************************}unit CnHardWareInfo;
{* |
================================================================================
* 软件名称:CnPack 组件包
* 单元名称:硬件信息单元
* 单元作者:SkyJacker
* LiuXiao
* 备 注:硬件信息单元,目前只实现获取多核、多CPU系统中指定CPU的序列号与占用率
* 开发平台:WindowsXP sp2 + Delphi 6.0 up2
* 兼容测试:Win2000/XP + Delphi 5、6
* 本 地 化:该单元中的字符串均符合本地化处理方式
* 单元标识:$Id: CnHardWareInfo.pas,v 1.4 2008/03/06 13:07:21 liuxiao Exp $
* 修改记录:2008.01.12 V1.1
* LiuXiao 加入对 CPU 占用率的读取
* 2007.01.23 V1.0
* 创建单元,实现功能
================================================================================
|
}interface{$I CnPack.inc}uses
Classes, Windows, SysUtils, ExtCtrls;
type
TCnCPUIdFormat = (ifContinuous, ifDashed);
{* CPU序列号显示样式
|
ifContinuous: -连续型
ifDashed: -使用分割符'-'分割
|
} TCnCpuId = class(TPersistent)
{CPU 信息类}
private
FTimer: TTimer;
FCPUCount: Integer;
FCPUIds: TStrings;
FCPUIdFormat: TCnCPUIdFormat;
FCPUUsageRead: Boolean;
FCPUUsage: array[0..255] of Integer; // 总不会超过 256 个 CPU 吧?
FCurCnt, FLastCnt: array[0..255] of Integer;
FAverageCPUUsage: Integer;
function GetFirstCPUId: string;
function GetCPUId(Index: Integer): string;
procedure SetCPUIdFormat(ACPUIdFormat: TCnCPUIdFormat);
function GetAverageCPUUsage: Integer;
function GetCPUUsage(Index: Integer): Integer;
function GetFirstCPUUsage: Integer; function RefreshCPUUsages: Cardinal; // 只被定时调用
procedure CpuUsageTimer(Sender: TObject);
public
constructor Create;
{* 构造函数,创建 FCPUIds 并调用 ReadCPUId}
destructor Destroy; override; procedure ReadCPUId;
{* 获得所有 CPU 内核的序列号,并存入 FCPUIds 列表} property CPUIdFormat: TCnCPUIdFormat read FCPUIdFormat write SetCPUIdFormat;
{* CPU 序列号显示样式}
property CPUCount: Integer read FCPUCount;
{* 系统中 CPU 核总数}
property FirstCPUId: string read GetFirstCPUId;
{* 获取首个 CPU 的 ID,用于单 CPU 系统}
property CPUId[Index: Integer]: string read GetCPUId;
{* 获得指定 CPU 的序列号。索引 Index 从 0 开始}
property CPUUsage[Index: Integer]: Integer read GetCPUUsage;
{* 获得指定 CPU 的占用率,0 到 100
需要说明的是,本类在 NT 系统上采用定时采样获得 CPU 的忙周期数再计算而来,
因此在刚实例化、未采样完成时,得到的 CPU 占用率可能有误。以下同。
}
property AverageCPUUsage: Integer read GetAverageCPUUsage;
{* 获得平均 CPU 占用率,0 到 100}
property FirstCPUUsage: Integer read GetFirstCPUUsage;
{* 获得首个 CPU 的占用率,0 到 100,用于单 CPU 系统}
end;implementationtype
_SYSTEM_BASIC_INFORMATION = record
Unknown: ULONG;
MaximumIncrement: ULONG;
PhysicalPageSize: ULONG;
NumberOfPhysicalPages: ULONG;
LowestPhysicalPage: ULONG;
HighestPhysicalPage: ULONG;
AllocationGranularity: ULONG;
LowestUserAddress: ULONG;
HighestUserAddress: ULONG;
ActiveProcessors: ULONG;
NumberProcessors: UCHAR;
end;
SYSTEM_BASIC_INFORMATION = _SYSTEM_BASIC_INFORMATION;
PSYSTEM_BASIC_INFORMATION = ^SYSTEM_BASIC_INFORMATION;
TSystemBasicInformation = SYSTEM_BASIC_INFORMATION;
PSystemBasicInformation = ^TSystemBasicInformation; SYSTEM_PROCESSOR_TIMES = packed record
IdleTime: LARGE_INTEGER;
KernelTime: LARGE_INTEGER;
UserTime: LARGE_INTEGER;
DpcTime: LARGE_INTEGER;
InterruptTime: LARGE_INTEGER;
InterruptCount: ULONG;
end;
TSystemProcessorTimes = SYSTEM_PROCESSOR_TIMES;
PSystemProcessorTimes = ^TSystemProcessorTimes;
SYSTEM_INFORMATION_CLASS = (
SystemBasicInformation,
SystemProcessorInformation,
SystemPerformanceInformation,
SystemTimeOfDayInformation,
SystemNotImplemented1,
SystemProcessesAndThreadsInformation,
SystemCallCounts,
SystemConfigurationInformation,
SystemProcessorTimes,
SystemGlobalFlag,
SystemNotImplemented2,
SystemModuleInformation,
SystemLockInformation,
SystemNotImplemented3,
SystemNotImplemented4,
SystemNotImplemented5,
SystemHandleInformation,
SystemObjectInformation,
SystemPagefileInformation,
SystemInstructionEmulationCounts,
SystemInvalidInfoClass1,
SystemCacheInformation,
SystemPoolTagInformation,
SystemProcessorStatistics,
SystemDpcInformation,
SystemNotImplemented6,
SystemLoadImage,
SystemUnloadImage,
SystemTimeAdjustment,
SystemNotImplemented7,
SystemNotImplemented8,
SystemNotImplemented9,
SystemCrashDumpInformation,
SystemExceptionInformation,
SystemCrashDumpStateInformation,
SystemKernelDebuggerInformation,
SystemContextSwitchInformation,
SystemRegistryQuotaInformation,
SystemLoadAndCallImage,
SystemPrioritySeparation,
SystemNotImplemented10,
SystemNotImplemented11,
SystemInvalidInfoClass2,
SystemInvalidInfoClass3,
SystemTimeZoneInformation,
SystemLookasideInformation,
SystemSetTimeSlipEvent,
SystemCreateSession,
SystemDeleteSession,
SystemInvalidInfoClass4,
SystemRangeStartInformation,
SystemVerifierInformation,
SystemAddVerifier,
SystemSessionProcessesInformation);
TSystemInformationClass = SYSTEM_INFORMATION_CLASS;
TNativeQuerySystemInformation = function(SystemInformationClass:
TSystemInformationClass; SystemInformation: Pointer; SystemInformationLength:
Cardinal; ReturnLength: PDWORD): Cardinal; stdcall;
http://www.cnpack.org/showdetail.php?id=666&lang=zh-cn
Unit CPUID; Delphi(Pascal) code{***********************************************
* 这个模块是用来获取CPU序列号,调用方式: *
* 在上层程序的uses子句中含CPUID模块,用函数 *
*调用 CPUID.GetCPUVendor 获得CPU的制造商名称; *
*调用 CPUID.GetCPUInfo 得到CPU的序列号. *
*************************************************}interfaceuses
SysUtils;type
TCPUID = array[1..4] of Longint;
TVendor = array [0..11] of char; function GetCPUID: TCPUID; assembler; register;
function GetCPUVendor: TVendor; assembler; register;
function GetCPUInfo: string;implementation
Function GetCPUID: TCPUID; assembler; register;
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;Function GetCPUVendor: TVendor; assembler; register;
asm
PUSH EBX {Save affected register}
PUSH EDI
MOV EDI,EAX {@Result (TVendor)}
MOV EAX,0
DW $A20F {CPUID Command}
MOV EAX,EBX
XCHG EBX,ECX {save ECX result}
MOV ECX,4
@1:
STOSB
SHR EAX,8
LOOP @1
MOV EAX,EDX
MOV ECX,4
@2:
STOSB
SHR EAX,8
LOOP @2
MOV EAX,EBX
MOV ECX,4
@3:
STOSB
SHR EAX,8
LOOP @3
POP EDI {Restore registers}
POP EBX
end;Function GetCPUInfo: string;
var
CPUID: TCPUID;
I: Integer;
begin
for I := Low(CPUID) to High(CPUID) do
CPUID[i]:=-1;
CPUID := GetCPUID;
Result := IntToHex(CPUID[1], 8) + IntToHex(CPUID[2], 8)
+ IntToHex(CPUID[3], 8)
+ IntToHex(CPUID[4], 8);
end; end.