来看这个dll怎么写?很简单!(100分)

  • 主题发起人 主题发起人 iapollo
  • 开始时间 开始时间
I

iapollo

Unregistered / Unconfirmed
GUEST, unregistred user!
在程序中这个dll是这么调用的<br>unit DiskSerial;<br><br>interface<br><br>type DISK_SERIAL = record<br>&nbsp; &nbsp; lpSerialNumber : array[0..31] of char;<br>&nbsp; &nbsp; lpModelNumber : array[0..31] of char;<br>&nbsp; &nbsp; lpRevisionNumber : array[0..31] of char;<br>&nbsp; &nbsp; lBufferSize : integer;<br>&nbsp; &nbsp; lCylinders : integer;<br>&nbsp; &nbsp; lHeads : integer;<br>&nbsp; &nbsp; lSectors : integer;<br>end;<br><br><br>function GetDiskSerial(nDrive:integer; var lpDiskSerial:DISK_SERIAL; lpRegNumber:PChar): LongBool;stdcall external 'DiskSerial.dll';<br><br><br>implementation<br><br>end.<br>现在我自己来写一个dll来替换这个dll。lpDiskSerial由自己随便输,如'abcdefgh'.
 
library DiskSerial;<br><br>{ Important note about DLL memory management: ShareMem must be the<br>&nbsp; first unit in your library's USES clause AND your project's (select<br>&nbsp; Project-View Source) USES clause if your DLL exports any procedures or<br>&nbsp; functions that pass strings as parameters or function results. This<br>&nbsp; applies to all strings passed to and from your DLL--even those that<br>&nbsp; are nested in records and classes. ShareMem is the interface unit to<br>&nbsp; the BORLNDMM.DLL shared memory manager, which must be deployed along<br>&nbsp; with your DLL. To avoid using BORLNDMM.DLL, pass string information<br>&nbsp; using PChar or ShortString parameters. }<br><br>uses<br>&nbsp; SysUtils,<br>&nbsp; Classes;<br><br>type DISK_SERIAL = record<br>&nbsp; &nbsp; lpSerialNumber :array[0..31] of char;<br>&nbsp; &nbsp; lpModelNumber : array[0..31] of char;<br>&nbsp; &nbsp; lpRevisionNumber : array[0..31] of char;<br>&nbsp; &nbsp; lBufferSize : integer;<br>&nbsp; &nbsp; lCylinders : integer;<br>&nbsp; &nbsp; lHeads : integer;<br>&nbsp; &nbsp; lSectors : integer;<br>end;<br><br>{$R *.res}<br>function GetDiskSerial(nDrive:integer; var lpDiskSerial:DISK_SERIAL; lpRegNumber:PChar): LongBool;stdcall;<br>begin<br>lpDiskSerial.lpSerialNumber:='abcdefghi';<br>Result:=true;<br>end;<br><br>exports<br>GetDiskSerial;<br><br>begin<br>end.<br>送分都没人要。这样吧,前十个进来的,每人十分。分散完就行。
 
你0点发贴问,1点自己发答案!高!
 
谢谢给我十分了.................<br>
 
多人接受答案了。
 
后退
顶部