data module在动态链接库(dll)开发中如何使用?最好能提供一段代码,谢谢!
解决方案 »
- DBGridEh的ftLookUp列的相关问题。
- 想自学delphi的网络方面的知识,请问书籍那本好呢?
- 如何截獲"Discard changes to this record?"並換成中文對話框?
- ODAC控件没有类似ADO的SORT方法吗?
- Pchar()是什么意思?
- 请教一个关于获得字符串位置的问题?
- 关于delphiADO连接sqlserver数据库联接服务器问题
- MDI窗口问题。
- 哪里有Object Pascal方面的书籍下载?
- 求 关于delphi 计量相关的 开发技术
- 求救!我运行 Web App Debugger(Default URL : http://localhost:1024/ServerInfo.ServerInfo) 后 ,不小心把ServerInfo.ServerInfo 清
- 有关ClassInfo问题
begin
add := x + y;
end;exports
add;
function b(a,b:integer):integer;external '你的dll文件路径及名称' name 'add';
或者
function b(a,b:integer):integer;external '你的dll文件路径及名称' index 1;动态:
1)把指定库模块装入内存:
var
HM:HMODULE;
HM:=LoadLibrary('你的dll文件路径及名称'); 2)捡取给定模块中函数的地址:
function add(a,b:integer):integer;//此函数与DLL中的函数相同
GetProcAddress(HM,@add);3)释放
function FreeLibrary(hLibModule: HMODULE): BOOL; stdcall;procedure TForm1.Button1Click(Sender: TObject);
在FormCreate中
Datamodule1 := TDataModule1.Create(Application);
在FormDestroy中
FreeAndNil(Datamodule1);
就行了
我都唔知,帮不了你,很遗憾
但是你可以从Dll里引出一些调用了DataModule对象方法的函数和过程,其做法和标准Dll导出函数没甚么两样。
只不过,你的Dll需要在加载时自动构造对象实例,并在卸载时自动析构它。