如何读取主板BIOS的序列号?(200分)

  • 主题发起人 主题发起人 juxd
  • 开始时间 开始时间
J

juxd

Unregistered / Unconfirmed
GUEST, unregistred user!
在Windows 2000下使用D5,如何通过API调用,读取主板BIOS的序列号?<br>请高手帮忙。<br>
 
try these:<br><br>&nbsp; uses SHA1, Base64; <br><br>&nbsp; function GetHashedBiosInfo: string; <br>&nbsp; var <br>&nbsp; &nbsp; SHA1Context: TSHA1Context; <br>&nbsp; &nbsp; SHA1Digest: TSHA1Digest; <br>&nbsp; begin <br>&nbsp; &nbsp; // Get the BIOS data <br>&nbsp; &nbsp; SetString(Result, PChar(Ptr($F0000)), $10000); <br>&nbsp; &nbsp; // Hash the string <br>&nbsp; &nbsp; SHA1Init(SHA1Context); <br>&nbsp; &nbsp; SHA1Update(SHA1Context, PChar(Result), Length(Result)); <br>&nbsp; &nbsp; SHA1Final(SHA1Context, SHA1Digest); <br>&nbsp; &nbsp; SetString(Result, PChar(@SHA1Digest), sizeof(SHA1Digest)); <br>&nbsp; &nbsp; // Return the hash string encoded in printable characters <br>&nbsp; &nbsp; Result := B64Encode(Result); <br>&nbsp; end; <br><br><br>&nbsp; function GetBiosInfoAsText: string; <br>&nbsp; var <br>&nbsp; &nbsp; p, q: pchar; <br>&nbsp; begin <br>&nbsp; &nbsp; q := nil; <br>&nbsp; &nbsp; p := PChar(Ptr($FE000)); <br>&nbsp; &nbsp; repeat <br>&nbsp; &nbsp; &nbsp; if q &lt;&gt; nil then begin <br>&nbsp; &nbsp; &nbsp; &nbsp; if not (p^ in [#10, #13, #32..#126, #169, #184]) then begin <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (p^ = #0) and (p - q &gt;= 8) then begin <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Result := Result + TrimRight(String(q)) + #13#10; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; q := nil; <br>&nbsp; &nbsp; &nbsp; &nbsp; end; <br>&nbsp; &nbsp; &nbsp; end else <br>&nbsp; &nbsp; &nbsp; &nbsp; if p^ in [#33..#126, #169, #184] then <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; q := p; <br>&nbsp; &nbsp; &nbsp; inc(p); <br>&nbsp; &nbsp; until p &gt; PChar(Ptr($FFFFF)); <br>&nbsp; &nbsp; Result := TrimRight(Result); <br>&nbsp; end; <br><br>&nbsp; procedure TForm1.FormCreate(Sender: TObject); <br>&nbsp; begin <br>&nbsp; &nbsp; Memo1.Lines.Text := GetBiosInfoAsText; <br>&nbsp; end; <br>
 
到《程序员大本营2000》找
 
我只知道win98下的方法,不过我知道有个很好的控件可以解决这些问题<br>http://go3.163.com/~delphi6/<br>SystemInformation v1.0可以获得所需的系统信息
 
以上的方法都是直接读取绝对内存地址,类似这样的方法<br>&nbsp; SetString(Result, PChar(Ptr($F0000)), $10000); <br>&nbsp; s := String(PChar(Ptr($FEC71))); (SystemInfomation的代码)<br>在2000下运行都会产生异常,无法获取信息
 
据我所知,windows的注册表中有相应的信息,所有常用的硬件的都有。没有modem的<br>CPU的频率没有。<br>认真看看注册表的内容吧!<br>有些时候不用写复杂的代码的!
 
版本,日期,厂商都有,就是没有序列号
 
to xk:<br>&nbsp; 请问sha1,base64在那?
 
SHA1, Base64是一种什么样的东西?!
 
好象是某加密算法中看过SHA1, Base64!
 
怎样才能在NT和2000中得到BIOS中的信息?
 
我也想知道!!!
 
关注。。<br>或者有没有人知道读主板序列号的端口而不只是内存地址。。
 
关注,如果那位知道,请给我发EMAIL.
 
cmos内存的读写 <br><br><br>一、CMOS内存信息详解 <br>一般的PC/AT、286、386、486等微机均配有CMOS芯片,CMOS&amp;127;芯片包含了一个实时钟 <br>和64个字节的CMOS内存。在CMOS内存中,0-0DH为实时钟的有关信息,0E-&amp;127;3FH包含 <br>计算机的硬件配置信息,如常规内存的大小、扩展内存的大小、&amp;127;软盘的类型、固定 <br>盘的类型及其物理参数、显示器的类型等,这些参数与计算机能否正常工作具有密切的 <br>关系,另外还有计算机的开机口令和其它辅助设置信息。表1列出了&amp;127;CMOS内存各字 <br>节的用途。 <br>表1 CMOS内存配置信息的含义 <br>地 址 <br>&nbsp;功能 <br>&nbsp;说明 <br>0,1 <br>&nbsp;秒,秒报警 <br>&nbsp;  <br>2,3 <br>&nbsp;分,分报警 <br>&nbsp;  <br>4,5 <br>&nbsp;时,时报警 <br>&nbsp;  <br>6 <br>&nbsp;星期几 <br>&nbsp;  <br>7,8,9 <br>&nbsp;日,月,年 <br>&nbsp;  <br>A <br>&nbsp;状态寄存器A <br>&nbsp;  <br>B <br>&nbsp;状态寄存器B <br>&nbsp;  <br>C <br>&nbsp;状态寄存器C <br>&nbsp;  <br>D <br>&nbsp;状态寄存器D <br>&nbsp;0=电池失效,80=电池有效 <br>E <br>&nbsp;诊断状态 <br>&nbsp;  <br>F <br>&nbsp;关机状态 <br>&nbsp;由上电诊断定义 <br>10 <br>&nbsp;软驱 <br>&nbsp;高4位为A驱,低4位为B驱,0=无, 1=360KB, 2=1.2KB, 4=1.44KB, 6=720KB <br>11 <br>&nbsp;保留 <br>&nbsp;  <br>12 <br>&nbsp;固定盘 <br>&nbsp;高4位为C驱,低4位为D驱,0=无,F=用户定义盘, 其它为系统定义盘 <br>13 <br>&nbsp;保留 <br>&nbsp;  <br>14 <br>&nbsp;设备状态 <br>&nbsp;标志驱动器数、显示器类型、有无数学处理器等 <br>15-16 <br>&nbsp;内存 <br>&nbsp;以KB计的常规内存数,100H=256KB,200H=512KB, 280H=640KB <br>17-18 <br>&nbsp;扩展内存 <br>&nbsp;以KB计的扩展内存数,200H=512KB,400H=1024KB等 <br>19 <br>&nbsp;C盘类型数 <br>&nbsp;根据具体硬盘类型而定 <br>1A <br>&nbsp;D盘类型数 <br>&nbsp;根据具体硬盘类型而定 <br>1B-1C <br>&nbsp;保留 <br>&nbsp;  <br>1D-1E <br>&nbsp;C盘柱体数 <br>&nbsp;1D-2CH只有当硬盘为用户自定义类型时起作用 <br>1F <br>&nbsp;C盘面数 <br>&nbsp;  <br>20-21 <br>&nbsp;C盘WP <br>&nbsp;  <br>22-23 <br>&nbsp;C盘LZ <br>&nbsp;  <br>24 <br>&nbsp;C盘每柱扇区   <br>25-26 <br>&nbsp;D盘柱体数 <br>&nbsp;  <br>27 <br>&nbsp;D盘面数 <br>&nbsp;  <br>28-29 <br>&nbsp;D盘WP   <br>2A-2B <br>&nbsp;D盘LZ   <br>2C <br>&nbsp;D盘每柱扇区   <br>2D <br>&nbsp;保留   <br>2E-2F <br>&nbsp;校验和 <br>&nbsp;为10-2DH共30个字节的和数,2EH为高位,2FH为低位 <br>30-31 <br>&nbsp;扩展内存   <br>32 <br>&nbsp;日期的世纪数 <br>&nbsp;BCD码的世纪值,如1995年的世纪数为19 <br>33 <br>&nbsp;标志信息   <br>34-3F <br>&nbsp;保留 <br>&nbsp;  <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *地址栏均为16进制表示 <br>二、读写CMOS内存的方法 <br>CMOS内存的地址口和数据口的口地址分别为70H和71H。在对CMOS内存进行写操作时,首先 <br>将要写入的CMOS内存的地址送到口地址70H,&amp;127;再将要写入的数据送口地址71H。在对 <br>CMOS内存进行读操作时,首先将要读出的CMOS内存的地址送到口地址70H,再从口地址71H <br>读出数据到AL寄存器。 <br>三、程序设计与使用 <br>为了方便系统信息丢失后CMOS信息的恢复,作者用BORLAND PASCAL&amp;127;设计了一个CMOS <br>.PAS的程序,它可以将CMOS内存中的信息直接写入文件,也可以把文件中的信息写入CMOS <br>内存,同时可以对CMOS内存中的信息进行编辑修改,并重新写回CMOS内存。它不仅解决了 <br>没有SETUP程序的计算机在加电时不能设置CMOS内存的问题,同时解决了CMOS信息的保存 <br>和恢复问题,是广大计算机用户的一个好帮手。 <br>该程序的使用很简单,在DOS提示符下打CMOS,即显示该程序的使用方法,&amp;127;具体使用 <br>方法是: <br>CMOS [/开关] <br>开关有3个: <br>R --- 读取CMOS内存信息,并将其存入CMOS.DAT的文件,共占64个字节。 <br>W --- 从CMOS.DAT中读取信息,并将其写入CMOS内存。&amp;127;注意这样写入的CMOS信息,其 <br>时间和日期是不正确的,写完之后应当用DOS命令DATE和TIME&amp;127;设置正确的日期和时间 <br>。 <br>M --- 从CMOS中读取当前信息,进行修改,然后将其写入CMOS内存和CMOS.DAT的文件。 <br>四、程序清单 <br>由于篇幅的限制,程序中略去了用TURBO &amp;127;VISION&amp;127;编写的程序界面部分。 <br>program CMOS; <br>type <br>TCMOSType = record <br>&nbsp; &nbsp; Seconds : byte; <br>&nbsp; &nbsp; SecondAlarm : byte; <br>&nbsp; &nbsp; Minutes : byte; <br>&nbsp; &nbsp; MinuteAlarm : byte; <br>&nbsp; &nbsp; Hours : byte; <br>&nbsp; &nbsp; HourAlarm : byte; <br>&nbsp; &nbsp; DayOfWeek : byte; <br>&nbsp; &nbsp; DayOfMonth : byte; <br>&nbsp; &nbsp; Month : byte; <br>&nbsp; &nbsp; Year : byte; <br>&nbsp; &nbsp; StatusRegA : byte; <br>&nbsp; &nbsp; StatusRegB : byte; <br>&nbsp; &nbsp; StatusRegC : byte; <br>&nbsp; &nbsp; StatusRegD : byte; <br>&nbsp; &nbsp; DiagStatus : Byte; <br>&nbsp; &nbsp; ShutDownStatus : Byte; <br>&nbsp; &nbsp; FloppyDrive : byte; <br>&nbsp; &nbsp; Reserved1 : byte; <br>&nbsp; &nbsp; FixedDrive : Byte; <br>&nbsp; &nbsp; Reserved2 : byte; <br>&nbsp; &nbsp; Equipment : byte; <br>&nbsp; &nbsp; RAM : word; <br>&nbsp; &nbsp; XMS : word; <br>&nbsp; &nbsp; FixedDriveType1 : byte; <br>&nbsp; &nbsp; FixedDriveType2 : byte; <br>&nbsp; &nbsp; Reserved3 : word; <br>&nbsp; &nbsp; Cylinder1 : word; <br>&nbsp; &nbsp; Head1 : byte; <br>&nbsp; &nbsp; WP1 : word; <br>&nbsp; &nbsp; LZ1 : word; <br>&nbsp; &nbsp; Sector1 : byte; <br>&nbsp; &nbsp; Cylinder2 : word; <br>&nbsp; &nbsp; Head2 : byte; <br>&nbsp; &nbsp; WP2 : word; <br>&nbsp; &nbsp; LZ2 : word; <br>&nbsp; &nbsp; Sector2 : byte; <br>&nbsp; &nbsp; Sys : byte; <br>&nbsp; &nbsp; CheckSum : word; <br>&nbsp; &nbsp; XMS1 : word; <br>&nbsp; &nbsp; DateCentury : byte; <br>&nbsp; &nbsp; InfoFlags : byte; <br>&nbsp; &nbsp; Reserved4: array[1..12] of byte; <br>end; <br>TByte64 = array[1..64] of byte; <br>TCMOS = object <br>&nbsp; &nbsp; CMOSRec : TCMOSType; <br>&nbsp; &nbsp; procedure ReadCMOS; <br>&nbsp; &nbsp; procedure WriteCMOS; <br>&nbsp; &nbsp; procedure DisplayCMOS; <br>&nbsp; &nbsp; procedure ModifyCMOS; <br>&nbsp; &nbsp; procedure ReadFile; <br>&nbsp; &nbsp; procedure WriteFile; <br>end; <br>procedure TCMOS.ReadFile; <br>var <br>&nbsp; &nbsp; f1 : file; <br>&nbsp; &nbsp; data : tbyte64 absolute CMOSRec; <br>&nbsp; &nbsp; ch : char; <br>begin <br>&nbsp; &nbsp; write('Please input the drive name (A/B/C/D): '); <br>&nbsp; &nbsp; readln(ch); <br>&nbsp; &nbsp; assign(f1,ch+':/CMOS.DAT'); <br>&nbsp; &nbsp; reset(f1,1); <br>&nbsp; &nbsp; blockread(f1,data,sizeof(data)); <br>&nbsp; &nbsp; close(f1); <br>end; <br>procedure TCMOS.WriteFile; <br>var <br>&nbsp; &nbsp; f1:file; <br>&nbsp; &nbsp; data : tbyte64 absolute CMOSRec; <br>&nbsp; &nbsp; ch : char; <br>begin <br>&nbsp; &nbsp; write('Please input the drive name (A/B/C/D): '); <br>&nbsp; &nbsp; readln(ch); <br>&nbsp; &nbsp; assign(f1,ch+':/CMOS.DAT'); <br>&nbsp; &nbsp; rewrite(f1,1); <br>&nbsp; &nbsp; blockwrite(f1,data,sizeof(data)); <br>&nbsp; &nbsp; close(f1); <br>end; <br>procedure TCMOS.ReadCMOS; <br>begin <br>asm <br>les di,self <br>add di,CMOSRec <br>MOV CX,40H <br>MOV AH,0H <br>MOV BX,0 <br>@1: <br>MOV DX,70H <br>MOV AL,AH <br>OUT DX,AL <br>INC DX <br>in AL,dx <br>MOV BYTE PTR es:[di+BX],al <br>INC AH <br>INC BX <br>DEC CX <br>JNZ @1 <br>end; <br>end; <br>procedure TCMOS.WriteCMOS; <br>begin <br>asm <br>les di,self <br>add di,CMOSRec <br>MOV CX,40H <br>MOV AH,0H <br>MOV BX,0 <br>@1: <br>MOV DX,70H <br>MOV AL,AH <br>OUT DX,AL <br>MOV AL,BYTE PTR es:[di+BX] <br>INC DX <br>OUT DX,AL <br>INC AH <br>INC BX <br>DEC CX <br>JNZ @1 <br>end; <br>end; <br>procedure TCMOS.DisplayCMOS; <br>var <br>hd1,hd2,fd1,fd2 : byte; <br>begin <br>Writeln(^J^M'CMOS RAM information:'); <br>writeln('Date(MM-DD-YY): ',CMOSRec.Month shr 4,CMOSRec.Month and $f, <br>'-',CMOSRec.DayOfMonth shr 4,CMOSRec.DayOfMonth and $f, <br>'-',CMOSRec.Year shr 4,CMOSRec.Year and $f); <br>writeln('Time(HH:MM:SS): ',CMOSRec.Hours shr 4,CMOSRec.Hours and $f, <br>':',CMOSRec.Minutes shr 4,CMOSRec.Minutes and $f, <br>':',CMOSRec.Seconds shr 4,CMOSRec.Seconds and $f); <br>writeln('Conventional Memory: ',CMOSRec.Ram,'KB'); <br>writeln('Extended Memory: ',CMOSRec.XMS,'KB'); <br>hd2 := CMOSRec.FixedDrive and $f; <br>hd1 := CMOSRec.FixedDrive shr 4; <br>if (hd1 &lt;&gt; 0) then <br>begin <br>writeln('Fixed Drive 1: ',CMOSRec.FixedDriveType1); <br>writeln(' Cylinder : ',CMOSRec.Cylinder1); <br>writeln(' Head : ',CMOSRec.Head1); <br>writeln(' Sector: ',CMOSRec.Sector1); <br>writeln(' LZ: ',CMOSRec.LZ1); <br>writeln(' WP: ',CMOSRec.WP1); <br>end; <br>if (hd2 &lt;&gt; 0) then <br>begin <br>writeln('Fixed Drive 2: ',CMOSRec.FixedDriveType2); <br>writeln(' Cylinder : ',CMOSRec.Cylinder2); <br>writeln(' Head : ',CMOSRec.Head2); <br>writeln(' Sector: ',CMOSRec.Sector2); <br>writeln(' LZ: ',CMOSRec.LZ2); <br>writeln(' WP: ',CMOSRec.WP2); <br>end; <br>fd2 := CMOSRec.FloppyDrive and $f; <br>fd1 := CMOSRec.FloppyDrive shr 4; <br>if (fd1 &lt;&gt; 0) then <br>begin <br>write('Floppy Drive 1 : '); <br>case fd1 of <br>1 : writeln('360KB 5.25'''); <br>2 : writeln('1.2MB 5.25'''); <br>4 : writeln('1.44MB 3.5'''); <br>6 : writeln('720KB 3.5'''); <br>end; <br>end ; <br>if (fd2 &lt;&gt; 0) then <br>begin <br>write('Floppy Drive 2 : '); <br>case fd2 of <br>1 : writeln('360KB 5.25'''); <br>2 : writeln('1.2MB 5.25'''); <br>4 : writeln('1.44MB 3.5'''); <br>6 : writeln('720KB 3.5'''); <br>end; <br>end; <br>end; <br>procedure TCMOS.ModifyCMOS; <br>var <br>hd1,hd2,fd1,fd2 : byte; <br>data : tbyte64 absolute CMOSRec; <br>i : word; <br>begin <br>Writeln('Please input CORRECT CMOS information !'); <br>write('Conventional Memory (',CMOSRec.ram,'KB): ');readln(CMOSRec.ram); <br>write('Extended Memory (',CMOSRec.XMS,'KB): ');readln(CMOSRec.XMS); <br>write('Type of Fixed Disk 1: (',CMOSRec.FixedDriveType1,'): ');readln(CMOSRe <br>c.FixedDriveType1); <br>write(' Cylinder (',CMOSRec.Cylinder1,'):'); readln(CMOSRec.Cylinder1); <br>write(' Head (',CMOSRec.Head1,'): ');readln(CMOSRec.Head1); <br>write(' Sector (',CMOSRec.Sector1,'): ');readln(CMOSRec.Sector1); <br>write(' LZ (',CMOSRec.LZ1,'): ');readln(CMOSRec.LZ1); <br>write(' WP (',CMOSRec.WP1,'): ');readln(CMOSRec.WP1); <br>write('Type of Fixed Disk 2: (',CMOSRec.FixedDriveType2,'): ');readln(CMOSRe <br>c.FixedDriveType2); <br>write(' Cylinder (',CMOSRec.Cylinder2,'):'); readln(CMOSRec.Cylinder2); <br>write(' Head (',CMOSRec.Head2,'): ');readln(CMOSRec.Head2); <br>write(' Sector (',CMOSRec.Sector2,'): ');readln(CMOSRec.Sector2); <br>write(' LZ (',CMOSRec.LZ2,'): ');readln(CMOSRec.LZ2); <br>write(' WP (',CMOSRec.WP2,'): ');readln(CMOSRec.WP2); <br>hd1 := 0; hd2 :=0; <br>if (CMOSRec.FixedDriveType1&gt;46) then hd1 := $f; <br>if (CMOSRec.FixedDriveType2&gt;46) then hd2 := $f; <br>CMOSRec.FixedDrive := hd1 shl 4 + hd2; <br>fd2 := CMOSRec.FloppyDrive and $f; <br>fd1 := CMOSRec.FloppyDrive shr 4; <br>write('Floppy Drive 1 ('); <br>case fd1 of <br>1 : write('360KB 5.25''): '); <br>2 : write('1.2MB 5.25''): '); <br>4 : write('1.44MB 3.5''): '); <br>6 : write('720KB 3.5''): '); <br>end; <br>readln(fd1); <br>write('Floppy Drive 2 ('); <br>case fd2 of <br>1 : write('360KB 5.25''): '); <br>2 : write('1.2MB 5.25''): '); <br>4 : write('1.44MB 3.5''): '); <br>6 : write('720KB 3.5''): '); <br>end; <br>readln(fd2); <br>CMOSRec.FloppyDrive := fd1 shl 4 + fd2; <br>CMOSRec.CheckSum := 0; <br>for i := 17 to 46 do inc(CMOSRec.CheckSum,data); <br>i := CMOSRec.CheckSum; <br>data[47] := hi(i); <br>data[48] := lo(i); <br>end; <br>procedure help; <br>begin <br>WriteLn('Syntex:'+^J^M+ <br>' CMOS /R --- read information from CMOS RAM '+^J^M+ <br>' and write it to CMOS.DAT file '+^J^M+ <br>' CMOS /W --- read configuration information from CMOS.DAT '+^J^M+ <br>' and write it to CMOS RAM'); <br>Writeln(' CMOS /M --- modify CMOS information and save it'^J^M+ <br>' Floppy Drive Type:'+^J^M+ <br>' 1 : 360KB 5.25'''+^J^M+ <br>' 2 : 1.2MB 5.25'''+^J^M+ <br>' 4 : 1.44MB 3.5'''+^J^M+ <br>' 6 : 720KB 3.5'''); <br>end; <br>var ch : char; <br>temp : string; <br>ICMOS : TCMOS; <br>begin <br>WriteLn('CMOS Proctector 1.00, Copyright (c) 1995 Dong Zhanshan'); <br>if paramcount = 1 then <br>begin <br>temp := paramstr(1); <br>ch := upcase(temp[2]); <br>case ch of <br>'M' : begin <br>ICMOS.ReadCMOS; <br>ICMOS.ModifyCMOS; <br>ICMOS.DisplayCMOS; <br>ICMOS.WriteFile; <br>ICMOS.WriteCMOS; <br>end; <br>'R' : begin <br>ICMOS.ReadCMOS; <br>ICMOS.DisplayCMOS; <br>ICMOS.WriteFile; <br>end; <br>'W' : begin <br>ICMOS.ReadFile; <br>ICMOS.DisplayCMOS; <br>ICMOS.WriteCMOS; <br>end; <br>else help; <br>end; <br>end <br>else <br>help; <br>end.
 

Similar threads

回复
0
查看
999
不得闲
D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
后退
顶部