如何生成一个dll文件,并且请给一个范例(50分)

  • 主题发起人 主题发起人 wqh0329
  • 开始时间 开始时间
W

wqh0329

Unregistered / Unconfirmed
GUEST, unregistred user!
如何生成一个dll文件,并且请给一个范例<br>小弟学delphi不久,想学习动态连接库调用,但是不知道<br>如何先生成一个dll文件,还请各位大虾指教,并且给出一个范例
 
好象是在New Project的时候指定吧,我也忘记了。
 
Delphi有Demo
 
看Demo和书
 
D4及以上版本:<br><br>&nbsp; New... -&gt; DLL<br>然后自己简单地写一个函数, 按照它的注释信息就可以了.<br><br>另外, 如果只是想学如何调用的话, 可以找个现成的DLL, 比如user32.dll,<br>然后看看MSDN中说的该DLL中有什么函数, 调用试试.<br><br>此外, 还可以参考Delphi的安装目录下的source/rtl/win下的文件windows.pas<br>也是调用DLL的.
 
<br>最好有编写DLL的格式说明! 还有调用DLL的例程!<br><br>我也想要一份!! :)<br><br>谁人能满足 ????
 
library minmax;<br><br>function Min(X, Y: Integer): Integer; stdcall;<br>begin<br>&nbsp; if X &lt; Y then Min := X else Min := Y;<br>end;<br><br>function Max(X, Y: Integer): Integer; stdcall;<br>begin<br>&nbsp; if X &gt; Y then Max := X else Max := Y;<br>end;<br><br>exports<br>&nbsp; Min,<br>&nbsp; Max;<br><br>begin<br>end.
 
implementation<br>&nbsp; function Min(X, Y: Integer): Integer; stdcall; external 'minmax.dll';<br>&nbsp; function Max(X, Y: Integer): Integer; stdcall; external 'minmax.dll';
 
//dll source<br>library mysum;<br>uses<br>&nbsp; SysUtils, Classes;<br>&nbsp; function makeasum(f:integer;s:integer):integer;export;<br>&nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp;makeasum:=f+s;<br>&nbsp; end;<br><br>exports<br>&nbsp; &nbsp; &nbsp; &nbsp;makeasum;<br>end.<br><br>// use dll<br>unit Unit1;<br><br>interface<br><br>uses<br>&nbsp; Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br>&nbsp; StdCtrls;<br><br>type<br>&nbsp; TForm1 = class(TForm)<br>&nbsp; &nbsp; Edit1: TEdit;<br>&nbsp; &nbsp; Edit2: TEdit;<br>&nbsp; &nbsp; Edit3: TEdit;<br>&nbsp; &nbsp; Button1: TButton;<br>&nbsp; &nbsp; procedure Button1Click(Sender: TObject);<br>&nbsp; private<br>&nbsp; &nbsp; { Private declarations }<br>&nbsp; public<br>&nbsp; &nbsp; { Public declarations }<br>&nbsp; end;<br><br>var<br>&nbsp; Form1: TForm1;<br><br>implementation<br>function makeasum(f:integer;s:integer):integer;far;external 'mysum';<br><br>{$R *.DFM}<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br>&nbsp; &nbsp; &nbsp;edit3.text:=inttostr(makeasum(strtoint(edit1.text),strtoint(edit2.text)));<br>end;<br><br>end.<br>
 
有给你发了一份帮助文件, 希望有用
 
对不起,现在才给你们的分,谢谢各位,特别是iknow ,zhengfei zyy04小弟在这里多谢了
 
后退
顶部