W
wuzhonglinquan
Unregistered / Unconfirmed
GUEST, unregistred user!
DLL与ADOConnection的问题
我自己做了有个测试,
在主程序里有个MainADOConnection,并设置好其ConnectionStrin属性,置Connected:=true;
在DLL里面也有个ADOConn控件,我希望主程序中的MainADOConnection传递到DLL中,并ADOConn:=MainADOConnection(我是认为是这样可以,不知道这样做行不行?)
主程序代码:
procedure TForm1.Button1Click(Sender: TObject);
var
hdll:THandle;
ShowMdll:TShowMdll;
begin
hdll:=LoadLibrary('pp.dll');
if hdll<>0 then
begin
@ShowMdll:=GetProcAddress(hdll,'ShowTLDForm');
if @ShowMdll<>nil then
ShowMdll(handle,DMform.ADOConnection1);
end;
end;
DLL代码:
library pp;
uses
Forms,ADODB,Dialogs,
UnitTLDForm in 'UnitTLDForm.pas' {TLDForm};
{$R *.res}
function ShowTLDForm(handle:THandle;AConn:TADOConnection):integer;stdcall;
var
TLDForm: TTLDForm;
begin
Application.Handle:=handle;
try
TLDForm:=TTLDForm.Create(Application);
Showmessage(TLDForm.ADOConnection1.ConnectionString);
result:=TLDForm.ShowModal;
TLDForm.ADOConnection1:=AConn;
TLDForm.ADOConnection1.Connected:=true;
finally
TLDForm.Free;
end;
end;
exports
showTLDForm;
begin
end.
测试的结果是弹出错误[ODBC数据源未连接],希望谁能指点一下??
我自己做了有个测试,
在主程序里有个MainADOConnection,并设置好其ConnectionStrin属性,置Connected:=true;
在DLL里面也有个ADOConn控件,我希望主程序中的MainADOConnection传递到DLL中,并ADOConn:=MainADOConnection(我是认为是这样可以,不知道这样做行不行?)
主程序代码:
procedure TForm1.Button1Click(Sender: TObject);
var
hdll:THandle;
ShowMdll:TShowMdll;
begin
hdll:=LoadLibrary('pp.dll');
if hdll<>0 then
begin
@ShowMdll:=GetProcAddress(hdll,'ShowTLDForm');
if @ShowMdll<>nil then
ShowMdll(handle,DMform.ADOConnection1);
end;
end;
DLL代码:
library pp;
uses
Forms,ADODB,Dialogs,
UnitTLDForm in 'UnitTLDForm.pas' {TLDForm};
{$R *.res}
function ShowTLDForm(handle:THandle;AConn:TADOConnection):integer;stdcall;
var
TLDForm: TTLDForm;
begin
Application.Handle:=handle;
try
TLDForm:=TTLDForm.Create(Application);
Showmessage(TLDForm.ADOConnection1.ConnectionString);
result:=TLDForm.ShowModal;
TLDForm.ADOConnection1:=AConn;
TLDForm.ADOConnection1.Connected:=true;
finally
TLDForm.Free;
end;
end;
exports
showTLDForm;
begin
end.
测试的结果是弹出错误[ODBC数据源未连接],希望谁能指点一下??