获取主板Bios信息
CoDelphi.com 摘 要:用Delphi调用Bios的信息
关键字:BIOS
类 别:系统控制
--------------------------------------------------------------------------------
添加一个Tbutton和一个Tmemo组件到窗体并写如下代码到按钮的OnClick事件:with Memo1.Lines do
begin
Add('MainBoardBiosName:'+^I+string(Pchar(Ptr($FE061))));
Add('MainBoardBiosCopyRight:'+^I+string(Pchar(Ptr($FE091))));
Add('MainBoardBiosDate:'+^I+string(Pchar(Ptr($FFFF5))));
Add('MainBoardBiosSerialNo:'+^I+string(Pchar(Ptr($FEC71))));
end; 以上代码在Win9X上运行通过。
中文开发在线www.codelphi.com授权使用。
CoDelphi.com 摘 要:用Delphi调用Bios的信息
关键字:BIOS
类 别:系统控制
--------------------------------------------------------------------------------
添加一个Tbutton和一个Tmemo组件到窗体并写如下代码到按钮的OnClick事件:with Memo1.Lines do
begin
Add('MainBoardBiosName:'+^I+string(Pchar(Ptr($FE061))));
Add('MainBoardBiosCopyRight:'+^I+string(Pchar(Ptr($FE091))));
Add('MainBoardBiosDate:'+^I+string(Pchar(Ptr($FFFF5))));
Add('MainBoardBiosSerialNo:'+^I+string(Pchar(Ptr($FEC71))));
end; 以上代码在Win9X上运行通过。
中文开发在线www.codelphi.com授权使用。
解决方案 »
- 我用idftp做的上传,打包后客户不能用!
- spcomm串口循环发送和接收,窗体的按钮反应慢问题,请进...
- MapX大侠,MapX如何能一次装载一个文件的内容?
- 在Delphi中如何导出Excel表呀?
- 高分求教delphi连oracle 10g出现ora-12154错误?
- 如何把doc或者rtf文档保存到SQL SERVER数据库的varbinary字段?
- 怎么让BUTTON透明?
- 各位老大,问一个极菜的问题,不要笑我!请问DataModule在哪里可以找到啊?哪个标签下啊?
- 我原来是学VB的,现在我想研究一下DELPHI又不知道从哪下手。
- 请问哪有好的image控件?delphi6自带的那个浏览bmp时图片上半部全黑!!!
- 急切求助!如何控制 richedit 编辑区与所灌入文本左侧的边距
- 一个很菜的问题 delphi中怎么判断输入字符的类型???? 谢谢
const
Subkey: string = ''Hardware\description\system'';
var
hkSB: HKEY;
rType: LongInt;
ValueSize, OrigSize: Longint;
ValueBuf: array[0..1000] of char;
procedure ParseValueBuf(const VersionType: string);
var
I, Line: Cardinal;
S: string;
begin
i := 0;
Line := 0;
while ValueBuf[i] <> #0 do
begin
S := StrPas(@ValueBuf[i]); // move the Pchar into a string
Inc(Line);
Memo1.Lines.Append(Format(''%s Line %d = %s'',
[VersionType, Line, S])); // add it to a Memo
inc(i, Length(S) + 1);
// to point to next sz, or to #0 if at
end
end;
end; begin
if RegOpenKeyEx(HKEY_LOCAL_MACHINE, PChar(Subkey), 0,
KEY_READ, hkSB) = ERROR_SUCCESS then
try
OrigSize := sizeof(ValueBuf);
ValueSize := OrigSize;
rType := REG_MULTI_SZ;
if RegQueryValueEx(hkSB, ''SystemBiosVersion'', nil, @rType,
@ValueBuf, @ValueSize) = ERROR_SUCCESS then
ParseValueBuf(''System BIOS Version''); ValueSize := OrigSize;
rType := REG_SZ;
if RegQueryValueEx(hkSB, ''SystemBIOSDate'', nil, @rType,
@ValueBuf, @ValueSize) = ERROR_SUCCESS then
Memo1.Lines.Append(''System BIOS Date '' + ValueBuf); ValueSize := OrigSize;
rType := REG_MULTI_SZ;
if RegQueryValueEx(hkSB, ''VideoBiosVersion'', nil, @rType,
@ValueBuf, @ValueSize) = ERROR_SUCCESS then
ParseValueBuf(''Video BIOS Version''); ValueSize := OrigSize;
rType := REG_SZ;
if RegQueryValueEx(hkSB, ''VideoBIOSDate'', nil, @rType,
@ValueBuf, @ValueSize) = ERROR_SUCCESS then
Memo1.Lines.Append(''Video BIOS Date '' + ValueBuf);
finally
RegCloseKey(hkSB);
end;
end;
How to read manufacturer's information from the ROM BIOS chip
Product:Delphi all versions
Uploader: Ernesto D'Spirito Company: Latium Software
Question/Problem/Abstract:
Different BIOS manufacturers have placed the serial numbers and other BIOS information in different memory locations, so the code you can usually find in the net to get this information might work with some machines but not with others...
Answer:For a simple copy-protection scheme we need to know whether the machine that is executing our application is the one where it was installed. We can save the machine data in the Windows Registry when the application is installed or executed for the first time, and then every time the application gets executed we compare the machine data with the one we saved to see if they are the same or not. But, what machine data should we use and how do we get it? In a past issue we showed how to get the volume serial number of a logical disk drive, but normally this is not satisfying for a software developer since this number can be changed. A better solution could be using the BIOS serial number. BIOS stands for Basic Input/Output System and basically is a chip on the motherboard of the PC that contains the initialization program of the PC (everything until the load of the boot sector of the hard disk or other boot device) and some basic device-access routines. Unfortunately, different BIOS manufacturers have placed the serial numbers and other BIOS information in different memory locations, so the code you can usually find in the net to get this information might work with some machines but not with others. However, most (if not all) BIOS manufacturers have placed the information somewhere in the last 8 Kb of the first Mb of memory, i.e. in the address space from $000FE000 to $000FFFFF. Assuming that "s" is a string variable, the following code would store these 8 Kb in it: SetString(s, PChar(Ptr($FE000)), $2000); // $2000 = 8196 We can take the last 64 Kb to be sure we are not missing anything: SetString(s, PChar(Ptr($F0000)), $10000); // $10000 = 65536 The problem is that it's ill-advised to store "large volumes" of data in the Windows Registry. It would be better if we could restrict to 256 bytes or less using some hashing/checksum technique. For example we can use the SHA1 unit (and optionally the Base64 unit) introduced in the issue #17 of the Pascal Newsletter: http://www.latiumsoftware.com/en/pascal/0017.php3 The code could look like the following: 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; This way we get a short string that we can save in the Windows Registry without any problems. The full source code example corresponding to this article is available for download: http://www.latiumsoftware.com/download/p0020.zip The full source code example of this article is available for download: http://www.latiumsoftware.com/download/p0020.zip
DISPLAYING BIOS INFORMATION
--------------------------- If we wanted to display the BIOS information we should parse the bytes to extract all null-terminated strings with ASCII printable characters at least 8-characters length, as it is done in the following function: 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; Then we can use the return value for example to display it in a memo: procedure TForm1.FormCreate(Sender: TObject);
begin
Memo1.Lines.Text := GetBiosInfoAsText;
end;
我运行你的第二个,得到和我的一样:
装inter 的cpu可以得到主板Bios,AMD的不可以