//Dll 部分<br>library Project4;<br><br>uses<br> Graphics;<br><br>{$R *.res}<br><br>procedure SetImage(var ABitmap: Pointer);<br>begin<br> TBitmap(ABitmap).LoadFromFile('c:/1.bmp');<br>end;<br><br>exports<br> SetImage;<br><br>begin<br>end.<br><br>//调用部分<br>unit Unit3;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> Dialogs, StdCtrls, ExtCtrls;<br><br>type<br> TForm1 = class(TForm)<br> Button1: TButton;<br> Image1: TImage;<br> procedure Button1Click(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br>var<br> Form1: TForm1;<br><br>procedure SetImage(var ABitmap: Pointer); stdcall;external 'Project4.dll';<br><br>implementation<br><br>{$R *.dfm}<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br> B: TBitmap;<br>begin<br> B := TBitmap.Create;<br> try<br> SetImage(Pointer(B));<br> Image1.Canvas.CopyRect(Rect(0,0,100,100),b.Canvas,Rect(0,0,100,100));<br> finally<br> B.Free;<br> end;<br>end;<br><br>end.