///////////求教菜鸟问题:关于DLL的用法。有代码/////////////

newmanJB 2005-09-08 04:58:45
//============不知在其它工程中如何调用=============
//=================================================
//======新建工程名为:Project1=====================

library Project1;

uses ... ...;

{$R *.res}

exports

Create index 1,
Destory index 7;

begin
end.

//=================================================
//======函数单元这在这里,就2个而已================

unit TTSDLL;

interface
uses VtxtAuto_TLB;

procedure Create;export; {待导出的过程和函数}
procedure Destory;export;

var
TTS: IVTxtauto;

implementation

procedure Create;
begin
TTS:=CoVTxtAuto_.Create; {创建对象}
TTS.Register('Project1','Project1'); {注册 }
end;

procedure Destory;
begin
TTS:=nil;{释放对象}
end;

end.
//================完===编译通过====================
//============不知如何在其它工程中调用=============
...全文
119 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
Larry1030 2005-09-10
  • 打赏
  • 举报
回复
在调用是也要引用 VtxtAuto_TLB
xixuemao 2005-09-10
  • 打赏
  • 举报
回复
那我就不明白了,你仅仅把创建和释放IVTxtauto的代码放到dll里面有什么意义呢?
newmanJB 2005-09-08
  • 打赏
  • 举报
回复
Please
newmanJB 2005-09-08
  • 打赏
  • 举报
回复
Help me
newmanJB 2005-09-08
  • 打赏
  • 举报
回复
先多谢两位:xixuemao(俺可是㊣②㈧经儿滴人) & zhaozhen2004(圣骑士)

一般的函数我会用,可上面代码我是想在其它工程中调用“TTS”啊。
申明的tts是IVTxtauto,调用时要怎样搞?
zhaozhen2004 2005-09-08
  • 打赏
  • 举报
回复
//============不知如何在其它工程中调用=============
procedure create;external 'project1.dll';
procedure destoty;external 'project1.dll'
xixuemao 2005-09-08
  • 打赏
  • 举报
回复
library mydll;

uses
SysUtils,
Classes,
windows;

{$R *.res}

function max(i,j: integer):integer; stdcall; export;
begin
if i > j then result:= i else result:= j;
end;

exports
max;

begin
end.
编译后生成dll文件。
========================
调用工程里
function max(i,j: integer):integer; external 'mydll.dll' name 'max';

1,183

社区成员

发帖
与我相关
我的任务
社区描述
Delphi Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧