要求获得CPU序列号和硬盘序列号代码 ( 积分: 100 )

  • 主题发起人 主题发起人 leguoguo
  • 开始时间 开始时间
L

leguoguo

Unregistered / Unconfirmed
GUEST, unregistred user!
硬盘序列号需支持IDE和SCSI的硬盘,谢谢
 
硬盘序列号需支持IDE和SCSI的硬盘,谢谢
 
得到硬盘序列号<br>var SerialNum : pdword; a, b : dword; Buffer : array [0..255] of char; <br>begin <br>if GetVolumeInformation('c:/', Buffer, SizeOf(Buffer), SerialNum, a, b, nil, 0) then Label1.Caption := IntToStr(SerialNum^); <br>end;
 
怎样得到CPU的序列号unit Main;<br><br>interface<br><br>uses &nbsp;Windows, &nbsp;Messages, &nbsp;SysUtils, &nbsp;Classes, &nbsp;Graphics, &nbsp;Controls,<br>Forms, &nbsp;Dialogs, &nbsp;ExtCtrls, &nbsp;StdCtrls, &nbsp;Buttons;<br><br>type<br>TDemoForm = class(TForm)<br>Label1: TLabel;<br>Label2: TLabel;<br>Label3: TLabel;<br>Label4: TLabel;<br>GetButton: TBitBtn;<br>CloseButton: TBitBtn;<br>Bevel1: TBevel;<br>Label5: TLabel;<br>FLabel: TLabel;<br>MLabel: TLabel;<br>PLabel: TLabel;<br>SLabel: TLabel;<br>PValue: TLabel;<br>FValue: TLabel;<br>MValue: TLabel;<br>SValue: TLabel;<br>procedure GetButtonClick(Sender: TObject);<br>end;<br><br>var<br>DemoForm: TDemoForm;<br><br>implementation<br><br>{$R *.DFM}<br><br>const<br>ID_BIT = $200000; &nbsp; // EFLAGS ID bit<br>type<br>TCPUID = array[1..4] of Longint;<br>TVendor = array [0..11] of char;<br><br>function IsCPUID_Available : Boolean; register;<br>asm<br>PUSHFD &nbsp; &nbsp; &nbsp; {direct access to flags no possible, only via stack}<br>POP &nbsp; &nbsp; EAX &nbsp; &nbsp; {flags to EAX}<br>MOV &nbsp; &nbsp; EDX,EAX &nbsp; {save current flags}<br>XOR &nbsp; &nbsp; EAX,ID_BIT {not ID bit}<br>PUSH &nbsp; &nbsp;EAX &nbsp; &nbsp; {onto stack}<br>POPFD &nbsp; &nbsp; &nbsp; &nbsp;{from stack to flags, with not ID bit}<br>PUSHFD &nbsp; &nbsp; &nbsp; {back to stack}<br>POP &nbsp; &nbsp; EAX &nbsp; &nbsp; {get back to EAX}<br>XOR &nbsp; &nbsp; EAX,EDX &nbsp; {check if ID bit affected}<br>JZ &nbsp; &nbsp; &nbsp;@exit &nbsp; &nbsp;{no, CPUID not availavle}<br>MOV &nbsp; &nbsp; AL,True &nbsp; {Result=True}<br>@exit:<br>end;<br><br>function GetCPUID : TCPUID; assembler; register;<br>asm<br>PUSH &nbsp; &nbsp;EBX &nbsp; &nbsp; &nbsp; &nbsp; {Save affected register}<br>PUSH &nbsp; &nbsp;EDI<br>MOV &nbsp; &nbsp; EDI,EAX &nbsp; &nbsp; {@Resukt}<br>MOV &nbsp; &nbsp; EAX,1<br>DW &nbsp; &nbsp; &nbsp;$A20F &nbsp; &nbsp; &nbsp; {CPUID Command}<br>STOSD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {CPUID[1]}<br>MOV &nbsp; &nbsp; EAX,EBX<br>STOSD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {CPUID[2]}<br>MOV &nbsp; &nbsp; EAX,ECX<br>STOSD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {CPUID[3]}<br>MOV &nbsp; &nbsp; EAX,EDX<br>STOSD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {CPUID[4]}<br>POP &nbsp; &nbsp; EDI &nbsp; &nbsp; {Restore registers}<br>POP &nbsp; &nbsp; EBX<br>end;<br><br>function GetCPUVendor : TVendor; assembler; register;<br>asm<br>PUSH &nbsp; &nbsp;EBX &nbsp; &nbsp; {Save affected register}<br>PUSH &nbsp; &nbsp;EDI<br>MOV &nbsp; &nbsp; EDI,EAX &nbsp; {@Result (TVendor)}<br>MOV &nbsp; &nbsp; EAX,0<br>DW &nbsp; &nbsp; &nbsp;$A20F &nbsp; &nbsp;{CPUID Command}<br>MOV &nbsp; &nbsp; EAX,EBX<br>XCHG &nbsp;EBX,ECX &nbsp; &nbsp; {save ECX result}<br>MOV &nbsp; ECX,4<br>@1:<br>STOSB<br>SHR &nbsp; &nbsp; EAX,8<br>LOOP &nbsp; &nbsp;@1<br>MOV &nbsp; &nbsp; EAX,EDX<br>MOV &nbsp; ECX,4<br>@2:<br>STOSB<br>SHR &nbsp; &nbsp; EAX,8<br>LOOP &nbsp; &nbsp;@2<br>MOV &nbsp; &nbsp; EAX,EBX<br>MOV &nbsp; ECX,4<br>@3:<br>STOSB<br>SHR &nbsp; &nbsp; EAX,8<br>LOOP &nbsp; &nbsp;@3<br>POP &nbsp; &nbsp; EDI &nbsp; &nbsp; {Restore registers}<br>POP &nbsp; &nbsp; EBX<br>end;<br><br>procedure TDemoForm.GetButtonClick(Sender: TObject);<br>var<br>CPUID : TCPUID;<br>I &nbsp; &nbsp; : Integer;<br>S &nbsp; : TVendor;<br>begin<br> &nbsp;for I := Low(CPUID) to High(CPUID) &nbsp;do CPUID := -1;<br> &nbsp;if IsCPUID_Available then begin<br> &nbsp; &nbsp;CPUID := GetCPUID;<br> &nbsp; &nbsp;Label1.Caption := 'CPUID[1] = ' + IntToHex(CPUID[1],8);<br> &nbsp; &nbsp;Label2.Caption := 'CPUID[2] = ' + IntToHex(CPUID[2],8);<br> &nbsp; &nbsp;Label3.Caption := 'CPUID[3] = ' + IntToHex(CPUID[3],8);<br> &nbsp; &nbsp;Label4.Caption := 'CPUID[4] = ' + IntToHex(CPUID[4],8);<br> &nbsp; &nbsp;PValue.Caption := IntToStr(CPUID[1] shr 12 and 3);<br> &nbsp; &nbsp;FValue.Caption := IntToStr(CPUID[1] shr 8 and $f);<br> &nbsp; &nbsp;MValue.Caption := IntToStr(CPUID[1] shr 4 and $f);<br> &nbsp; &nbsp;SValue.Caption := IntToStr(CPUID[1] and $f);<br> &nbsp; &nbsp;S := GetCPUVendor;<br> &nbsp; &nbsp;Label5.Caption := 'Vendor: ' + S; end<br> &nbsp;else begin<br> &nbsp; &nbsp;Label5.Caption := 'CPUID not available';<br> &nbsp;end;<br>end;<br><br>end.
 
赶紧SEARCH,到处都是!
 
//////////////////////////////////////////////////////////////////////////////<br> &nbsp;//18.取得网卡物理地址MAC &nbsp; AdapterID 网卡序号,如果只有一块网卡 AdapterID=0,<br> &nbsp;// &nbsp; MACID 地址段序号 0-6 &nbsp;0代表全部段 &nbsp; 须引用NB30单元<br> &nbsp;//////////////////////////////////////////////////////////////////////////////<br>Function NBGetAdapterAddress(AdapterID,MACID:integer) : String;<br>Var<br> &nbsp;NCB : TNCB; // Netbios control block //NetBios控制块<br> &nbsp;ADAPTER : TADAPTERSTATUS; // Netbios adapter status//取网卡状态<br> &nbsp;LANAENUM : TLANAENUM; // Netbios lana<br> &nbsp;intIdx : Integer; // Temporary work value//临时变量 <br> &nbsp;cRC : Char; // Netbios return code//NetBios返回值<br> &nbsp;strTemp : String; // Temporary string//临时变量<br>Begin<br> &nbsp;// Initialize <br> &nbsp;Result := '';<br> &nbsp;Try<br> &nbsp; &nbsp;// Zero control blocl<br> &nbsp; &nbsp;ZeroMemory(@NCB, SizeOf(NCB));<br><br> &nbsp; &nbsp;// Issue enum command <br> &nbsp; &nbsp;NCB.ncb_command := Chr(NCBENUM); <br> &nbsp; &nbsp;cRC := NetBios(@NCB); <br><br> &nbsp; &nbsp;// Reissue enum command <br> &nbsp; &nbsp;NCB.ncb_buffer := @LANAENUM; <br> &nbsp; &nbsp;NCB.ncb_length := SizeOf(LANAENUM); <br> &nbsp; &nbsp;cRC := NetBios(@NCB); <br> &nbsp; &nbsp;If Ord(cRC)&lt;&gt;0 Then<br> &nbsp; &nbsp; &nbsp;exit; <br><br> &nbsp; &nbsp;// Reset adapter <br> &nbsp; &nbsp;ZeroMemory(@NCB, SizeOf(NCB)); <br> &nbsp; &nbsp;NCB.ncb_command := Chr(NCBRESET); <br> &nbsp; &nbsp;NCB.ncb_lana_num := LANAENUM.lana[AdapterID];<br> &nbsp; &nbsp;cRC := NetBios(@NCB); <br> &nbsp; &nbsp;If Ord(cRC)&lt;&gt;0 Then <br> &nbsp; &nbsp; &nbsp;exit; <br><br> &nbsp; &nbsp;// Get adapter address <br> &nbsp; &nbsp;ZeroMemory(@NCB, SizeOf(NCB)); <br> &nbsp; &nbsp;NCB.ncb_command := Chr(NCBASTAT); <br> &nbsp; &nbsp;NCB.ncb_lana_num := LANAENUM.lana[AdapterID];<br> &nbsp; &nbsp;StrPCopy(NCB.ncb_callname, '*'); <br> &nbsp; &nbsp;NCB.ncb_buffer := @ADAPTER; <br> &nbsp; &nbsp;NCB.ncb_length := SizeOf(ADAPTER); <br> &nbsp; &nbsp;cRC := NetBios(@NCB); <br><br> &nbsp; &nbsp;// Convert it to string<br> &nbsp; &nbsp;strTemp := '';<br> &nbsp; &nbsp;if MACID=0 then<br> &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp;For intIdx := 0 To 5 Do<br> &nbsp; &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp; &nbsp;strTemp :=strTemp+InttoHex(Integer(ADAPTER.adapter_address[intIdx]),2);<br> &nbsp; &nbsp; &nbsp; &nbsp;if intidx&lt;&gt;5 then<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;strTemp:=strTemp+'-';<br> &nbsp; &nbsp; &nbsp;end;<br> &nbsp; &nbsp;end<br> &nbsp; &nbsp;else<br> &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp;strTemp :=InttoHex(Integer(ADAPTER.adapter_address[MACID-1]),2);<br> &nbsp; &nbsp;end;<br> &nbsp; &nbsp;Result := strTemp;<br> &nbsp;Finally<br> &nbsp;End;<br>End;
 
我有这方面的控件,可以获取IDE、SCSI(无法在win98下获取,死机!)硬盘的序列号,CPU速度(可能无法正确获取笔记本电脑的),网卡地址。<br>可以有偿提供源码!<br><br>荷塘新月(QQ:57151728,htxy99@yahoo.com)<br>欢迎大家访问我的网站: www.startor.cn
 

Similar threads

回复
0
查看
591
不得闲
回复
0
查看
1K
不得闲
回复
0
查看
797
不得闲
D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
后退
顶部