急!急!急! Delphi编程读取 P III 序列号???(100分)

  • 主题发起人 主题发起人 chaoro
  • 开始时间 开始时间
C

chaoro

Unregistered / Unconfirmed
GUEST, unregistred user!
  如何用 DELPHI编程读取 PIII 处理器的序列号?
 
不急不急,PIII的资料还不多。
 
先说一说要干什么
 
有一张光盘有提过,好像是"DELPHI掌中宝",可以自己去找找,如果找不到,可以通知过!
 
分太少这么难的题目,500分还差不多!<br>重开题给500分就告诉你!
 
to robert.l<br>分是很重要的但是更重要的是解决问题,如果单纯为分不要来了算,。
 
网上找来的旧代码,取 CPU ID,不是你所谓的 P3 的序列号<br><br>滥竽充数一下吧!!<br><br>=============================================================================<br>unit CPUID;<br><br>interface<br><br>type<br>&nbsp; TCPUID = array[1..4] of Longint;<br>&nbsp; TCPUVendor = array[0..11] of Char;<br><br>function GetCPUID: TCPUID; assembler; register;<br>function GetCPUVendor: TCPUVendor; assembler; register;<br><br>implementation<br><br>function GetCPUID: TCPUID; assembler; register;<br>asm<br>&nbsp; PUSH &nbsp; &nbsp;EBX &nbsp; &nbsp; &nbsp; &nbsp; {Save affected register}<br>&nbsp; PUSH &nbsp; &nbsp;EDI<br>&nbsp; MOV &nbsp; &nbsp; EDI,EAX &nbsp; &nbsp; {@Resukt}<br>&nbsp; MOV &nbsp; &nbsp; EAX,1<br>&nbsp; DW &nbsp; &nbsp; &nbsp;$A20F &nbsp; &nbsp; &nbsp; {CPUID Command}<br>&nbsp; STOSD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {CPUID[1]}<br>&nbsp; MOV &nbsp; &nbsp; EAX,EBX<br>&nbsp; STOSD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {CPUID[2]}<br>&nbsp; MOV &nbsp; &nbsp; EAX,ECX<br>&nbsp; STOSD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {CPUID[3]}<br>&nbsp; MOV &nbsp; &nbsp; EAX,EDX<br>&nbsp; STOSD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {CPUID[4]}<br>&nbsp; POP &nbsp; &nbsp; EDI &nbsp; &nbsp; &nbsp; &nbsp; {Restore registers}<br>&nbsp; POP &nbsp; &nbsp; EBX<br>end;<br><br>function GetCPUVendor: TCPUVendor; assembler; register;<br>asm<br>&nbsp; PUSH &nbsp; &nbsp;EBX &nbsp; &nbsp; &nbsp; &nbsp; {Save affected register}<br>&nbsp; PUSH &nbsp; &nbsp;EDI<br>&nbsp; MOV &nbsp; &nbsp; EDI,EAX &nbsp; &nbsp; {@Result (TVendor)}<br>&nbsp; MOV &nbsp; &nbsp; EAX,0<br>&nbsp; DW &nbsp; &nbsp; &nbsp;$A20F &nbsp; &nbsp; &nbsp;{CPUID Command}<br>&nbsp; MOV &nbsp; &nbsp; EAX,EBX<br>&nbsp; XCHG &nbsp; &nbsp;EBX,ECX &nbsp; &nbsp; {save ECX result}<br>&nbsp; MOV &nbsp; &nbsp; ECX,4<br>@1:<br>&nbsp; STOSB<br>&nbsp; SHR &nbsp; &nbsp; EAX,8<br>&nbsp; LOOP &nbsp; &nbsp;@1<br>&nbsp; MOV &nbsp; &nbsp; EAX,EDX<br>&nbsp; MOV &nbsp; &nbsp; ECX,4<br>@2:<br>&nbsp; STOSB<br>&nbsp; SHR &nbsp; &nbsp; EAX,8<br>&nbsp; LOOP &nbsp; &nbsp;@2<br>&nbsp; MOV &nbsp; &nbsp; EAX,EBX<br>&nbsp; MOV &nbsp; &nbsp; ECX,4<br>@3:<br>&nbsp; STOSB<br>&nbsp; SHR &nbsp; &nbsp; EAX,8<br>&nbsp; LOOP &nbsp; &nbsp;@3<br>&nbsp; POP &nbsp; &nbsp; EDI &nbsp; &nbsp; &nbsp; &nbsp; {Restore registers}<br>&nbsp; POP &nbsp; &nbsp; EBX<br>end;<br><br>end.<br>=============================================================================<br>
 
李颖的代码在论坛上已经贴出来多次了但那是不行的只能取得的PIII产品代码,<br>对同一批产品就取得全是相同的了, &nbsp;这我已经试验过!<br><br>to loopy:<br>分对我们穷人还是有用的,我的方法还没有完全成功,<br>或许你的高分能让我更有动力快快完成呢^&amp;^<br><br>=========重赏之下必有勇夫===========<br><br>要不大富翁也就不用实行大富翁制了...
 
robert.l:<br>你把东西拿出来给大家,我给你500分,您看行么?<br>我的email<br>h@sun.net.cn<br>
 
我也想知道。
 
to loopy: 我是穷人我想要分^&amp;^<br>to thtfsyh,我相信你了不过现在不发布确实是还没完全成功,分我还是要的未完成的<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;代码也给你吧<br>to chaoro: 我现在只能给你VC的代码启示一下以后可进一步讨论!<br><br>to all:<br>&nbsp; 本问题的关键是一条未公开的指新令CPUID,他提代的功能号01,03分别取得<br>cpuid的前32位和后64位,加起来就是96位的PIIIcpu序列号。 我已经与intel<br>提供的工具cpuid取得的id比较验证过是对的!<br>&nbsp; 但我发现这条指令竞然只有VC有,delphi4,delphi5都没有提供,我在delphi<br>中测试失败,看来只有期待delphi6来解决了<br>&nbsp; 现在公开的是vc6下的代码可有了它,你完全可以作一个dll,ocx什么在delphi中<br>调用, &nbsp;我就是这样实现的如要这个现成的ocx,请与我联系:<br><br>&nbsp; &nbsp; email: &nbsp;hbliao@jobroad.net<br><br>=======================================================================<br><br>CString CGetcpuidCtrl::GetCpuId()<br>{<br> // TODO: Add your control notification handler code here<br> int EAX_,EDX_,ECX_;<br> CString rst="",rst2,rst3;<br><br> __asm{<br>&nbsp; &nbsp; &nbsp;MOV EAX,01H<br>&nbsp; &nbsp; &nbsp;CPUID<br>&nbsp; &nbsp; &nbsp;MOV EAX_,EAX<br>&nbsp; &nbsp; &nbsp;MOV EDX_,EDX<br> }<br> if (EDX_ &amp; 0x00000100)//此位为1表示此cpu有序列号<br> {<br>&nbsp; &nbsp; &nbsp; &nbsp; rst.Format("%8x",EAX_);<br> __asm{<br> MOV EAX,03H<br> CPUID<br> MOV EDX_,EDX<br> MOV ECX_,ECX<br> }<br> rst2.Format("%8x",EDX_);<br> rst3.Format("%8x",ECX_);<br> rst.Format("%s%s%s",rst,rst2,rst3);<br> }<br> else<br> {<br> rst="This Cpu Not Have PIII serialno"; }<br> return(rst);<br>}<br>
 
欢迎大家继续讨论!<br>怎样能将分值提高到 &nbsp;200 &nbsp;分!
 
2 robert.l:<br><br>既然你的代码可用,那么剩下的问题就简单了,<br><br>现在你无法实现 CPUID 这个指令吗?<br><br>如下即可:<br>asm<br>&nbsp; MOV EAX,03H<br>&nbsp; &lt;font color=red&gt;&lt;b&gt;CPUID &nbsp;=====&gt; 修改为 DB $xx&lt;/b&gt;&lt;/font&gt;<br>&nbsp; MOV EDX_,EDX<br>&nbsp; MOV ECX_,ECX<br>end;<br><br>也就是说用 DB 指令强制定义一个(?)字节在这里<br>这个字节的内容就是 CPUID 指令翻译为 16进制后的结果<br>具体的数值可以通过你用 VC 编写的程序中得到<br><br><br>不过我看你所谓的 "CPUID" 指令好象就和前面贴出来的代码中写的是一回事<br>如果是这样的话,应该就是 DW $A20F
 
to 李颖:<br><br>我在线下也通过VC找到了cpuid的指令,确实是0f a2<br>并我已经用它在delphi实现了如下:<br>==============================================<br>var<br>&nbsp; EAX_,EDX_,ECX_:integer;<br>&nbsp; S:string;<br>&nbsp; I:Byte;<br><br>begin <br>&nbsp; &nbsp;asm<br>&nbsp; &nbsp; &nbsp;MOV EAX,01H<br>&nbsp; &nbsp; &nbsp;db $0f<br>&nbsp; &nbsp; &nbsp;db $a2<br>&nbsp; &nbsp; &nbsp;MOV EAX_,EAX<br>&nbsp; &nbsp; &nbsp;MOV EDX_,EDX<br>&nbsp; &nbsp;end;<br>&nbsp; &nbsp;if (EDX_ and $00000100)&lt;&gt;0 then<br>&nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp; s:=Formats(EAX_);<br>&nbsp; &nbsp; &nbsp; &nbsp; asm<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;MOV EAX,03H<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;db $0f<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;db $a2<br> &nbsp; MOV EDX_,EDX<br> &nbsp; MOV ECX_,ECX<br>&nbsp; &nbsp; &nbsp; &nbsp; end;<br> s:=s+Formats(EDX_);<br> s:=s+Formats(ECX_);<br>&nbsp; &nbsp;end<br>&nbsp; &nbsp;else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;s:='This Cpu Not Have PIII serialno';<br><br>=============================================<br><br>刚才我上线重看了你的代码,我想你可能未真正理解你自己贴出来代码的含义,<br>我已经解释过cpuid指令有功能号:0,1,2,3,而在你的GetCPUID中只取了1号功能,<br>这里的代码便是cpu的所谓产品代号部分,固此大家用这个函数取得的不能唯一,<br>同类cpu便相同了,而对3号功能取重要的后64位却给放掉了,ok,这便是我对你的<br>程序的理解!<br><br>欢迎大家多讨论...<br>
 
感谢 &nbsp;robert.l, 感谢 李颖,感谢大家!
 
有人试过正确吗?我怎么读出的内容与我朋友机器的一模一样。<br><br>to robert.1:<br>&nbsp; intel提供读cpuid的工具是什么软件?
 
后退
顶部