怎样得到主板系列号?(200分)

T

test01

Unregistered / Unconfirmed
GUEST, unregistred user!
已查阅过很多相关资料,但总是达不到目的。我需要在WIN2000下得到主板系列号。98下已经
实现。找到一个朋友的代码如下:
function GetMachineID:word;assembler;
asm
xor ax,ax
dec ax
mov es,ax//程序执行到这里就会出错。
mov ax,word ptr es:[$0e] {return}
end;

----------------兄弟不懂汇编,哪位兄台能指点一二?
 
xor ax,ax// ax=0;
dec ax// ax=ax-1;
mov es,ax// es=-1;
你现在知道为什么出错了吧!
 
es:附加段0xffff
实际存放主机号地址的位置[0ffffe]
我也运行不过,我在网上找到一段这样的取主机序列号的代码
FSerial := String(Pchar(Ptr($FEC71)));
存在0FEC71位置,我也运行不过,我估计是不是不同主板的序列号存在内存的不同位置(纯属推测)。
 
给你一段代码,你可以试试;
procedure TForm1.BiosInfo;
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 <> #0 do
begin
S := StrPas(@ValueBuf); // 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;
 
http://go3.163.com/~delphi6/SystemInformation v1.0
控件
 
谢谢。。。我马上试试myangel兄所说的控件。
 
我只是来指出下面代码的错误原因:

其一:
function GetMachineID:word;assembler;
asm
xor ax,ax
dec ax
mov es,ax//程序执行到这里就会出错。因为Delphi编译出来的是32为的机器码,ES是古老的16为段地址,所以...
mov ax,word ptr es:[$0e] {return}
end;

其二:
就算你可以换为
mov ax,word ptr [ecx] { ecx假设已经等于你原来的es*16+$0e }
在2K或XP下因为访问了不属于你的进程的页面地址,将出错(访问了无效的虚拟地址!)
 
顶部