library Project1dll;
{ Important note about DLL memory management: ShareMem must be the
first unit in your library's USES clause AND your project's (select
View-Project Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the DELPHIMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using DELPHIMM.DLL, pass string information
using PChar or ShortString parameters. }
uses
SysUtils,
Classes,
DllForm in 'DllForm.pas' {frmDllForm};
procedure ShowDllForm;stdcall;
begin
frmDllForm :=TfrmDllForm.Create(nil);
frmDllForm.Show;
end;
function ShowDllFormModal:integer;stdcall;
begin
frmDllForm :=TfrmDllForm.Create(nil);
Result := frmDllForm.ShowModal;
end;
Exports
ShowDllForm,
ShowDllFormModal ;
begin
end.
以下是DllForm.pas文件内容
unit DllForm;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
type
TfrmDllForm = class(TForm)
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frmDllForm: TfrmDllForm;
implementation
{$R *.DFM}
procedure TfrmDllForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action := caFree;
end;
procedure TfrmDllForm.FormCreate(Sender: TObject);
begin
end;
end.
注意:DllForm.pas文件中,一定在关闭时,一定要用Action := caFree;这Form释放,否则其它程序调用时,在开发环境中执行调用用,会报内存错误,我是在PB环境中,直接导致PB程序退出
阅读(742) | 评论(0) | 转发(0) |