获取CPU序列号代码如下:
function TZgxsFrm.GetHashedBiosInfo: string;
var
SHA1Context:TSHA1Context;
SHA1Digest:TSHA1Digest;
begin
// Get the BIOS data
SetString(Result, PChar(Ptr($F0000)), $10000);
// Hash the string
SHA1Init(SHA1Context);
SHA1Update(SHA1Context, PChar(Result), Length(Result));
SHA1Final(SHA1Context, SHA1Digest);
SetString(Result, PChar(@SHA1Digest), sizeof(SHA1Digest));
// Return the hash string encoded in printable characters
Result := B64Encode(Result);
end;
function TZgxsFrm.GetBiosInfoAsText: string;
var
p, q: pchar;
begin
q := nil;
p := PChar(Ptr($FE000));
repeat
if q <> nil then begin
if not (p^ in [#10, #13, #32..#126, #169, #184]) then begin
if (p^ = #0) and (p - q >= 8) then begin
Result := Result + TrimRight(String(q)) + #13#10;
end;
q := nil;
end;
end else
if p^ in [#33..#126, #169, #184] then
q := p;
inc(p);
until p > PChar(Ptr($FFFFF));
Result := TrimRight(Result);
end;
function TZgxsFrm.GetHashedBiosInfo: string;
var
SHA1Context:TSHA1Context;
SHA1Digest:TSHA1Digest;
begin
// Get the BIOS data
SetString(Result, PChar(Ptr($F0000)), $10000);
// Hash the string
SHA1Init(SHA1Context);
SHA1Update(SHA1Context, PChar(Result), Length(Result));
SHA1Final(SHA1Context, SHA1Digest);
SetString(Result, PChar(@SHA1Digest), sizeof(SHA1Digest));
// Return the hash string encoded in printable characters
Result := B64Encode(Result);
end;
function TZgxsFrm.GetBiosInfoAsText: string;
var
p, q: pchar;
begin
q := nil;
p := PChar(Ptr($FE000));
repeat
if q <> nil then begin
if not (p^ in [#10, #13, #32..#126, #169, #184]) then begin
if (p^ = #0) and (p - q >= 8) then begin
Result := Result + TrimRight(String(q)) + #13#10;
end;
q := nil;
end;
end else
if p^ in [#33..#126, #169, #184] then
q := p;
inc(p);
until p > PChar(Ptr($FFFFF));
Result := TrimRight(Result);
end;
[错误] UZgxsFrm.pas(38): Illegal character in input file: ' ' ($A1A1)
[错误] UZgxsFrm.pas(38): Undeclared identifier: 'TSHA1Context'
[错误] UZgxsFrm.pas(39): Illegal character in input file: ' ' ($A1A1)
[错误] UZgxsFrm.pas(39): Undeclared identifier: 'TSHA1Digest'
[错误] UZgxsFrm.pas(41): Illegal character in input file: ' ' ($A1A1)
[错误] UZgxsFrm.pas(42): Illegal character in input file: ' ' ($A1A1)
[错误] UZgxsFrm.pas(43): Illegal character in input file: ' ' ($A1A1)
[错误] UZgxsFrm.pas(44): Illegal character in input file: ' ' ($A1A1)
[错误] UZgxsFrm.pas(45): Illegal character in input file: ' ' ($A1A1)
[错误] UZgxsFrm.pas(46): Illegal character in input file: ' ' ($A1A1)
[错误] UZgxsFrm.pas(47): Illegal character in input file: ' ' ($A1A1)
[错误] UZgxsFrm.pas(48): Illegal character in input file: ' ' ($A1A1)
[错误] UZgxsFrm.pas(49): Illegal character in input file: ' ' ($A1A1)
[错误] UZgxsFrm.pas(49): Undeclared identifier: 'B64Encode'
[错误] UZgxsFrm.pas(53): Illegal character in input file: ' ' ($A1A1)
[错误] UZgxsFrm.pas(55): Illegal character in input file: ' ' ($A1A1)
[错误] UZgxsFrm.pas(56): Illegal character in input file: ' ' ($A1A1)
[错误] UZgxsFrm.pas(57): Illegal character in input file: ' ' ($A1A1)
[错误] UZgxsFrm.pas(58): Illegal character in input file: ' ' ($A1A1)
[错误] UZgxsFrm.pas(59): Illegal character in input file: ' ' ($A1A1)
[错误] UZgxsFrm.pas(60): Illegal character in input file: ' ' ($A1A1)
[错误] UZgxsFrm.pas(61): Illegal character in input file: ' ' ($A1A1)
[错误] UZgxsFrm.pas(62): Illegal character in input file: ' ' ($A1A1)
[错误] UZgxsFrm.pas(63): Illegal character in input file: ' ' ($A1A1)
[错误] UZgxsFrm.pas(64): Illegal character in input file: ' ' ($A1A1)
[错误] UZgxsFrm.pas(65): Illegal character in input file: ' ' ($A1A1)
[错误] UZgxsFrm.pas(66): Illegal character in input file: ' ' ($A1A1)
[错误] UZgxsFrm.pas(67): Illegal character in input file: ' ' ($A1A1)
[错误] UZgxsFrm.pas(68): Illegal character in input file: ' ' ($A1A1)
[错误] UZgxsFrm.pas(69): Illegal character in input file: ' ' ($A1A1)
[错误] UZgxsFrm.pas(70): Illegal character in input file: ' ' ($A1A1)
function GetCPUInfo: string;
var CPUID: TCPUID;
I: Integer;
S: TVendor;
begin
for I:=Low(CPUID) to High(CPUID) do CPUID[I]:=-1;
if IsCPUID_Available then
begin
CPUID:= GetCPUID;
S:=GetCPUVendor;
Result:= IntToHex(CPUID[1], 8)+ //'-'+
IntToHex(CPUID[2], 8)+ //'-'+
IntToHex(CPUID[3], 8)+ //'-'+
IntToHex(CPUID[4], 8);
end
else Result:='CPUID not available';
end;
function GetHashedBiosInfo: string;
function GetBiosInfoAsText: string;
再次声明一下,我从网上找到这两个函数,是为了
[获取主板ID],
由于写帖子写错了,写成了"获取CPU序列号代码"
[获取主板ID],
由于写帖子写错了,写成了"获取CPU序列号代码"
读取主板序列号uses SHA1, Base64;
function GetHashedBiosInfo: string;
var
SHA1Context: TSHA1Context;
SHA1Digest: TSHA1Digest;
begin
// Get the BIOS data
SetString(Result, PChar(Ptr($F0000)), $10000);
// Hash the string
SHA1Init(SHA1Context);
SHA1Update(SHA1Context, PChar(Result), Length(Result));
SHA1Final(SHA1Context, SHA1Digest);
SetString(Result, PChar(@SHA1Digest), sizeof(SHA1Digest));
// Return the hash string encoded in printable characters
Result := B64Encode(Result);
end;
function GetBiosInfoAsText: string;
var
p, q: pchar;
begin
q := nil;
p := PChar(Ptr($FE000));
repeat
if q <> nil then begin
if not (p^ in [#10, #13, #32..#126, #169, #184]) then begin
if (p^ = #0) and (p - q >= 8) then begin
Result := Result + TrimRight(String(q)) + #13#10;
end;
q := nil;
end;
end else
if p^ in [#33..#126, #169, #184] then
q := p;
inc(p);
until p > PChar(Ptr($FFFFF));
Result := TrimRight(Result);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Memo1.Lines.Text := GetBiosInfoAsText;
end;
源程序调试出错呀》》》》》》》》》》》》》》
//错误如下:
[错误] UZgxsFrm.pas(38): Illegal character in input file: ' ' ($A1A1)
[错误] UZgxsFrm.pas(38): Undeclared identifier: 'TSHA1Context'
[错误] UZgxsFrm.pas(39): Illegal character in input file: ' ' ($A1A1)
[错误] UZgxsFrm.pas(39): Undeclared identifier: 'TSHA1Digest'
[错误] UZgxsFrm.pas(41): Illegal character in input file: ' ' ($A1A1)
[错误] UZgxsFrm.pas(42): Illegal character in input file: ' ' ($A1A1)
[错误] UZgxsFrm.pas(43): Illegal character in input file: ' ' ($A1A1)
[错误] UZgxsFrm.pas(44): Illegal character in input file: ' ' ($A1A1)
[错误] Unit1.pas(55): Undeclared identifier: 'TVendor'
[错误] Unit1.pas(58): Undeclared identifier: 'IsCPUID_Available'
[错误] Unit1.pas(60): Undeclared identifier: 'GetCPUID'
[错误] Unit1.pas(61): Undeclared identifier: 'GetCPUVendor'
[错误] Unit1.pas(237): Undeclared identifier: 'Result'
[致命错误] Project1.dpr(5): Could not compile used unit 'Unit1.pas'