如题,调用该对象又该怎么办?
解决方案 »
- 高手请进来,dephi调用C++dll,不成功,为什么?
- 使用FastReport进行单据打印的难题
- CommaText是何意思?最好给一个例子
- Tstringlist怎么老提示List index out of bounds(-1)?
- 如何在SQL语句里精确小数点以后的位数不清
- 关于ADO...
- 请问哪里有odac下载?(不是试用版的)
- 有没有开发VCL控件的书介绍??
- 第一次做报表,问个简单问题送分
- 如何用nmsmtp想需要身份验证的smtp server发邮件
- 怎样避免ADO中JOIN来的表被更新?
- **老问题,关于Twebbrowser的,ihihonline (小小)大哥问过的,解决高分**
library Dll;
uses
SysUtils,windows,
Classes,Controls,Forms,
DllForm in 'DllForm.pas' ;
{$R *.res}
var
DllApp:TApplication;
{ 用于初始化:保存DLL本身的Application,然后设置DLL的Application指向Host的Application }
procedure InitDLL(App:TApplication);stdcall;
begin
DllApp:=Application;
Application:=App;
end;
{ 善后工作:恢复DLL原来的Application }
procedure FreeDLL;stdcall;
begin
Application:=DllApp;
end;
{ 返回一个窗体对象,这是DLL的主要功能 }
function GetDllChildForm(Parent:TComponent):TFrmDLLChild;stdcall;
begin
Result := TFrmDLLChild.Create(Parent);
end;
exports
InitDLL,FreeDLL,GetDllChildForm;
begin
end.function GetDllChildForm(Parent:TComponent):TFrmDllChild;stdcall;external 'dll.dll';
procedure InitDLL(App:TApplication);stdcall;external 'dll.dll';
procedure FreeDLL;stdcall;external 'dll.dll';
procedure TForm1.FormCreate(Sender: TObject);
begin
InitDLL(Application);
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
FreeDLL;
end;
调用窗体代码:
var
DForm:TFrmDllChild;
begin
DForm :=DllFunction(Application,Self);
DForm.Show;
end;
http://dev.csdn.net/article/29/29053.shtm
这样有很好的二进制兼容性,在C++也能使用这个对象。