Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2339355
  • 博文数量: 321
  • 博客积分: 3440
  • 博客等级: 中校
  • 技术积分: 2992
  • 用 户 组: 普通用户
  • 注册时间: 2007-05-24 09:08
个人简介

我就在这里

文章分类

全部博文(321)

文章存档

2015年(9)

2014年(84)

2013年(101)

2012年(25)

2011年(29)

2010年(21)

2009年(6)

2008年(23)

2007年(23)

分类: Python/Ruby

2012-12-26 16:46:56

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程序退出

阅读(5313) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~