1,183
社区成员
发帖
与我相关
我的任务
分享
//------ 取CPU序列号 uses WinSock
function F_GetCPUID: string;
procedure SetCPU(Handle: THandle; CPUNO: Integer);
var
ProcessAffinity: Cardinal;
_SystemAffinity: Cardinal;
begin
GetProcessAffinityMask(handle, ProcessAffinity, _SystemAffinity);
ProcessAffinity := CPUNO;
SetProcessAffinityMask(handle, ProcessAffinity);
end;
const
CPUINFO = '%.8x-%.8x-%.8x-%.8x';
var
iEax: Integer;
iEbx: Integer;
iEcx: Integer;
iEdx: Integer;
begin
SetCPU(GetCurrentProcess, 1);
asm
push ebx
push ecx
push edx
mov eax, 1
DW $A20F//cpuid
mov iEax, eax
mov iEbx, ebx
mov iEcx, ecx
mov iEdx, edx
pop edx
pop ecx
pop ebx
end;
Result := Format(CPUINFO, [iEax, iEbx, iEcx, iEdx]);
end;
//获取网卡
function MacAddress: string;
var
Lib: Cardinal;
Func : function(GUID: PGUID): Longint; stdcall;
GUID1, GUID2: TGUID;
begin
Result := '';
Lib := LoadLibrary('rpcrt4.dll');
if Lib <> 0 then
begin
if Win32Platform <>VER_PLATFORM_WIN32_NT then
@Func := GetProcAddress(Lib, 'UuidCreate')
else @Func := GetProcAddress(Lib, 'UuidCreateSequential');
if Assigned(Func) then
begin
if (Func(@GUID1) = 0) and
(Func(@GUID2) = 0) and
(GUID1.D4[2] = GUID2.D4[2]) and
(GUID1.D4[3] = GUID2.D4[3]) and
(GUID1.D4[4] = GUID2.D4[4]) and
(GUID1.D4[5] = GUID2.D4[5]) and
(GUID1.D4[6] = GUID2.D4[6]) and
(GUID1.D4[7] = GUID2.D4[7]) then
begin
Result :=
IntToHex(GUID1.D4[2], 2) + '-' +
IntToHex(GUID1.D4[3], 2) + '-' +
IntToHex(GUID1.D4[4], 2) + '-' +
IntToHex(GUID1.D4[5], 2) + '-' +
IntToHex(GUID1.D4[6], 2) + '-' +
IntToHex(GUID1.D4[7], 2);
end;
end;
FreeLibrary(Lib);
end;
end;