采用Runtime Package
Project -> Option -> Packages 选中 Build with runtime packages
下面输入框里保留RTL,VCL编译就可以了。
发布时别忘了把RTL100.BPL和VCL100.BPL带着(在System32中,我的是Delphi2006,
别的版本数字不同)。
DLL文件
library Project33;
uses
SysUtils,
Classes,
Graphics;
{$R *.res}
procedure DrawIt(const bmp: TBitmap);
begin
bmp.Canvas.Pen.Color := clRed;
bmp.Canvas.Ellipse(10, 10, bmp.Width-10, bmp.Height-10);
end;
exports DrawIt;
begin
end.
主程序:
program Project32;
uses
Forms,
Unit31 in 'Unit31.pas' {Form31};
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TForm31, Form31);
Application.Run;
end.
unit Unit31;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm31 = class(TForm)
Button1: TButton;
Image1: TImage;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form31: TForm31;
implementation
{$R *.dfm}
procedure DrawIt(bmp: TBitmap); external 'project33.dll';
procedure TForm31.Button1Click(Sender: TObject);
begin
DrawIt(Image1.Picture.Bitmap);
end;
end.