各位大哥: 能帮我一把吗?有请。。。(100分)

  • 主题发起人 主题发起人 凤仙花
  • 开始时间 开始时间

凤仙花

Unregistered / Unconfirmed
GUEST, unregistred user!
<br>&nbsp; &nbsp; &nbsp;我是新手,慕名Delphi而苦苦地学起了Delphi!!!不知有何捷径能让我快速掌握Delphi的数据库编程技术?<br>&nbsp; &nbsp;<br>&nbsp; &nbsp; &nbsp;既然来了,何不帮我新手一把?!:<br>【我要提的问题】: 如何用delphi取得: CPU硬件编号、硬盘物理系列号(不是格式化系列号)?我想这是你们高手发布程序时都是要用到的加密问题,应该是小事一桩!<br>&nbsp; &nbsp; &nbsp;有完整的例子文件吗?<br>&nbsp; &nbsp; &nbsp;先谢谢个位了!<br>
 
找控件了
 
哪个控件?<br>哪里有?<br>谢谢~<br>
 
借花献佛;取得硬盘序列号:<br>Function GetHardDiskSerieNummer : string;<br>var<br>&nbsp; Teller &nbsp; &nbsp; &nbsp;: integer;<br>&nbsp; Lus &nbsp; &nbsp; &nbsp; &nbsp; : integer;<br>&nbsp; SerieNummer : array[0..24] of char;<br>begin<br>&nbsp; result := '';<br>&nbsp; Teller := 1;<br>&nbsp; for Lus := 1 to 8 do<br>&nbsp; begin<br>&nbsp; &nbsp;SerieNummer[Teller] := chr((HardDiskGegevens[10+Lus] div 256 ));<br>&nbsp; &nbsp;inc(Teller);<br>&nbsp; &nbsp;SerieNummer[Teller] := CHR((HardDiskGegevens[10+Lus] mod 256 ));<br>&nbsp; &nbsp;inc(Teller);<br>&nbsp; end;<br>&nbsp; result := SerieNummer;<br>&nbsp;end;<br>取得CPU编号:<br>TCPUIDARRAY=array[1..4] of Longint;<br>function GetCPUID : TCPUIDARRAY; 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 {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 {Restore registers}<br>&nbsp; POP &nbsp; &nbsp; EBX<br>end; <br>
 
以下转载自:http://www.delphiok.com/,即delphi技巧网<br>--------------------------------》》》》》》》》》》<br>&nbsp;69、如何在DELPHI5中通过程序获取计算机一系列硬件信息? &nbsp; <br>1、申明部份:<br>uses ....Winsock,Registry,NB30....<br>......<br>implementation<br>......<br>var s4,s5:string;<br>type<br>TNBLanaResources = (lrAlloc, lrFree);<br>type<br>PMACAddress = ^TMACAddress;<br>TMACAddress = array[0..5] of Byte;<br>type<br>TGate = record<br>Off2,op,seg,off1:WORD;<br>end;<br>LONGDWORD = INT64;<br>var<br>IDTR: LONGDWORD;<br>SavedGate:TGate;<br>OurGate: TGate;<br>dd: array [0..256] of word;<br>dsn:array [0..20] of char;<br>{$R *.DFM}<br><br>//以下函数用以获得硬盘出厂序列号。<br>procedure Ring0Proc();<br>asm<br>// Wait for controller not busy<br>mov dx,01f7h<br>@1:in al,dx<br>cmp al,050h<br>jne @1<br>// Get first/second drive<br>dec dx<br>mov al,0a0h<br>out dx,al<br>// Get drive info data<br>inc dx<br>mov al,0ech<br>out dx,al<br>nop<br>nop<br>// Wait for data ready<br>@2:in al,dx<br>cmp al,058h<br>jne @2<br>nop<br>nop<br>// Read sector<br>xor ecx,ecx<br>mov dx,01f0h<br>@3:in ax,dx<br>mov word ptr dd[ecx*2],ax<br>inc ecx<br>cmp ecx,256<br>jne @3<br>iretd<br>end;<br>procedure Change2Ring0();<br>begin<br>asm<br>mov eax, offset Ring0Proc<br>mov OurGate.off2, ax<br>shr eax, 16<br>mov OurGate.off1, ax<br>mov OurGate.op,0028h<br>mov OurGate.seg,0ee00h<br>mov ebx,offset IDTR<br>sidt [ebx]<br>mov ebx, dword ptr [IDTR+2]<br>add ebx, 8*3<br>mov edi, offset SavedGate<br>mov esi, ebx<br>movsd<br>movsd<br>mov edi, ebx<br>mov esi, offset OurGate<br>cli<br>movsd<br>movsd<br>sti<br>mov eax,6200h<br>mov ecx,0<br>int 3h<br>mov edi, ebx<br>mov esi, offset SavedGate<br>cli<br>movsd<br>movsd<br>sti<br>end;<br>asm<br>xor ecx,ecx<br>mov ebx,offset dd[10*2]<br>@4:mov ax,[ebx]<br>mov byte ptr dsn[ecx],ah<br>inc ecx<br>mov byte ptr dsn[ecx],al<br>inc ebx<br>inc ebx<br>inc ecx<br>cmp ecx,10<br>jne @4<br>end;<br>showmessage(dsn);<br>end;<br><br>//以下函数用以获得系统时间。<br>function GetSystemTime : AnsiString;<br>var<br>stSystemTime : TSystemTime;<br>begin<br>Windows.GetSystemTime( stSystemTime );<br>Result := DateTimeToStr( SystemTimeToDateTime( stSystemTime ) );<br>end;<br><br>//以下函数用以获得本地时间。<br>function GetLocalTime : AnsiString;<br>var<br>stSystemTime : TSystemTime;<br>begin<br>Windows.GetLocalTime( stSystemTime );<br>Result := DateTimeToStr( SystemTimeToDateTime( stSystemTime ) );<br>end;<br><br>//以下函数用以获得计算机名。<br>function GetComputerName: AnsiString;<br>var lpBuffer: array[0..MAX_PATH] of char;<br>dwSize: DWORD;<br>begin<br>dwSize:= MAX_PATH;<br>if not Windows.GetComputerName(lpBuffer, dwSize) then<br>raise<br>Exception.Create(SysErrorMessage(GetLastError()));<br>Result:= StrPas(lpBuffer);<br>end;<br>{function GetUserName: AnsiString;<br>var lpBuffer: array[0..MAX_PATH] of char;<br>dwSize: DWORD;<br>begin<br>dwSize:= MAX_PATH;<br>if not Windows.GetUserName(lpBuffer, dwSize) then<br>raise Exception.Create(SysErrorMessage(GetLastError()));<br>Result:= StrPas(lpBuffer);<br>end;}<br><br>//以下函数用以获得计算机BIOS系统信息。<br>function GetBios(value: integer): String;<br>// 1...Bios Type<br>// 2.. Bios Copyright<br>// 3.. Bios Date<br>// 4.. Bios Extended Info<br>// 5.. Bustype<br>// 6.. MachineType<br>begin<br>result:='(unavailable)';<br>case value of<br>1: result:=String(Pchar(Ptr($FE061)));<br>2: result:=String(Pchar(Ptr($FE091)));<br>3: result:=String(Pchar(Ptr($FFFF5)));<br>4: result:=String(Pchar(Ptr($FEC71)));<br>end;<br>end;<br><br>//以下函数是用以获得WINDOWS序列号函数中所调用的函数。<br>Function HexByte( b : Byte ) : String;<br>Const<br>Hex : Array[ $0..$F ] Of Char = '0123456789ABCDEF';<br>Begin<br>HexByte := Hex[ b Shr 4 ] + Hex[ b And $F ];<br>End;<br>Function HexWord( w : Word ) : String;<br>Begin<br>HexWord := HexByte( Hi( w ) ) + HexByte( Lo( w ) );<br>End;<br>Function DecToHex( aValue : LongInt ) : String;<br>Var<br>w : Array[ 1..2 ] Of Word Absolute aValue;<br>Begin<br>Result := HexWord( w[ 2 ] ) + HexWord( w[ 1 ] );<br>End;<br><br>//以下函数用以获得网卡地址。<br>function GetMACAddress(LanaNum: Byte; MACAddress: PMACAddress): Byte;<br>var<br>AdapterStatus: PAdapterStatus;<br>StatNCB: PNCB;<br>begin<br>New(StatNCB);<br>ZeroMemory(StatNCB, SizeOf(TNCB));<br>StatNCB.ncb_length := SizeOf(TAdapterStatus) + 255 * SizeOf(TNameBuffer);<br>GetMem(AdapterStatus, StatNCB.ncb_length);<br>try<br>with StatNCB^ do<br>begin<br>ZeroMemory(MACAddress, SizeOf(TMACAddress));<br>ncb_buffer := PChar(AdapterStatus);<br>ncb_callname := '* ' + #0;<br>ncb_lana_num := Char(LanaNum);<br>ncb_command := Char(NCBASTAT);<br>NetBios(StatNCB);<br>Result := Byte(ncb_cmd_cplt);<br>if Result = NRC_GOODRET then<br>MoveMemory(MACAddress, AdapterStatus, SizeOf(TMACAddress));<br>end;<br>finally<br>FreeMem(AdapterStatus);<br>Dispose(StatNCB);<br>end;<br>end;<br>function GetLanaEnum(LanaEnum: PLanaEnum): Byte;<br>var<br>LanaEnumNCB: PNCB;<br>begin<br>New(LanaEnumNCB);<br>ZeroMemory(LanaEnumNCB, SizeOf(TNCB));<br>try<br>with LanaEnumNCB^ do<br>begin<br>ncb_buffer := PChar(LanaEnum);<br>ncb_length := SizeOf(TLanaEnum);<br>ncb_command := Char(NCBENUM);<br>NetBios(LanaEnumNCB);<br>Result := Byte(ncb_cmd_cplt);<br>end;<br>finally<br>Dispose(LanaEnumNCB);<br>end;<br>end;<br><br>//以下函数用以得本机IP地址。<br>function LocalIP : string;<br>type<br>TaPInAddr = array [0..10] of PInAddr;<br>PaPInAddr = ^TaPInAddr;<br>var<br>phe : PHostEnt;<br>pptr : PaPInAddr;<br>Buffer : array [0..63] of char;<br>I : Integer;<br>GInitData : TWSADATA;<br>begin<br>WSAStartup($101, GInitData);<br>Result := '';<br>GetHostName(Buffer, SizeOf(Buffer));<br>phe :=GetHostByName(buffer);<br>if phe = nil then Exit;<br>pptr := PaPInAddr(Phe^.h_addr_list);<br>I := 0;<br>while pptr^ &lt;&gt; nil do begin<br>result:=StrPas(inet_ntoa(pptr^^));<br>Inc(I);<br>end;<br>WSACleanup;<br>end;<br><br>//以下函数用以获得WINDOWSID号。<br>function GetWindowsProductID: string;<br>var<br>reg:TRegistry;<br>begin<br>Result := '';<br>reg := TRegistry.Create;<br>with reg do<br>begin<br>RootKey := HKEY_LOCAL_MACHINE;<br>OpenKey('Software', False);<br>Result := ReadString('ProductID');<br>end;<br>reg.Free;<br>end;<br><br>//以下是在窗口出现时,显示计算机的硬件信息。<br>procedure TForm2.FormCreate(Sender: TObject);<br>var s0,s1,s2,s3:string;<br>//s4,s5:string为全程变量<br>n1,n2:longint;<br>myfile:textfile;<br>users:pchar;<br>i:dword;<br><br>MACAddress: PMACAddress;<br>RetCode: Byte;<br>var fulldrive :string[3];<br>tmp_drive :array[0..2] of char;<br>VolName :array[0..255] of Char;<br>SerialN :DWORD;<br>MaxCLength :DWORD;<br>FileSysFlag :DWORD;<br>FileSysName :array[0..255] of Char;<br>begin<br>Label2.Caption:='你的IP地址是: '+LocalIP;<br>label3.caption:='你的windowsID是:'+GetWindowsProductID;<br>New(MACAddress);<br>try<br>RetCode := GetMACAddress(0, MACAddress);<br>if RetCode = NRC_GOODRET then<br>begin<br>label5.caption := '你的网卡地址是:'+Format('%2.2x-%2.2x-%2.2x-%2.2x-%2.2x-%2.2x',<br>[MACAddress[0], MACAddress[1], MACAddress[2],<br>MACAddress[3], MACAddress[4], MACAddress[5]]);<br>end;<br>finally<br>Dispose(MACAddress);<br>end;<br>i:=255;<br>getmem(users,255);<br>getusername(users,i); //获得Windows用户名<br>label6.caption:='你登录windows的用户名是 :'+users;<br>freemem(users);<br>fulldrive:='c:;<br>strpcopy(tmp_drive,fulldrive);<br>GetVolumeInformation(tmp_drive, VolName, 255, @SerialN, MaxCLength,FileSysFlag, FileSysName, 255);<br>label7.caption:='你的硬盘卷标是:'+VolName;<br>label8.caption:='你的硬盘序列号是:'+DecToHex(SerialN);<br>label9.caption:='你的计算机名是:'+getcomputername;<br>IF getbios(1)&lt;&gt;'' then<br>label10.caption:='你的BIOS版本号是:'+getbios(1)<br>else<br>label10.caption:='未取得BIOS版本号';<br>if getbios(2)&lt;&gt;'' then<br>label11.caption:='你的BIOS序列号是:'+getbios(4)<br>else<br>label11.caption:='未取得BIOS序列号';<br>if getsystemtime&lt;&gt;'' then<br>label12.caption:='你的系统时间是:'+getsystemtime<br>else<br>label12.Caption:='未取得系统时间';<br>if getlocaltime&lt;&gt;'' then<br>label13.caption:='你的本地时间是:'+getlocaltime<br>else<br>label13.caption:='未取得本地时间';<br>if inttostr(DiskSize(3) div 1024)&lt;&gt;'' then<br>label14.caption:='你的系统硬盘空间是:'+inttostr(DiskSize(3) div 1024)<br>else<br>label14.caption:='未取得系统硬盘间';<br>procedure TForm2.Button2Click(Sender: TObject);<br>begin<br>Change2Ring0();<br>end;<br><br>说明:<br>&nbsp; &nbsp; 由于以上操作需要在申明处加入:Winsock,Registry,NB30<br>&nbsp; &nbsp; 以上方法在DELPHI5、WINDOWS98下通过。 &nbsp;<br>
 
不知怎么回事~我总是不能delphi7编译、运行!<br>各位大哥,好人做到底,能否干脆做个示例工程发到我mail好吗?谢谢~<br>fxhua1979@163.com<br>
 

Similar threads

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