Subject | Re: [IBO] dbhandle Help my |
---|---|
Author | Dmitry Beloshistov |
Post date | 2003-10-08T07:14:22Z |
Hello!
Try this code example:
In DLL:
===============================
Procedure InitPlugin(ApplicationHandle:THandle); stdcall;
begin
Application.Handle:=ApplicationHandle;
DM:=TDM.Create(Application); // my data module with IB_Connection
end;
Procedure InitIBCon(IBConnectionHandle:Pointer); stdcall;
begin
//-- initiate connection
DM.IB_Connection1.dbHandleShared:=IBConnectionHandle; //!!!!
{
Warning! dbHandleShared in DLL := dbHandle from host Application
}
//---------- etc....-------------------------------
end;
In your main project (host application):
======================================
type
TInitPlugin=procedure (AppHandle:THandle); stdcall;
TInitIBConnection=procedure (IBConHandle:pointer); stdcall;
var FPluginHandle:THandle; // loaded DLL handle
FInitPlugin=TInitPlugin;
FInitIBConnection=TInitIBConnection;
Procedure LoadPlugin;
begin
FPluginHandle:=LoadLibrary('MYDLLNAME.DLL'); // DLL loading
if FPluginHandle<>0 then
begin
@FInitPlugin:=GetProcAddress(FPluginHandle,'InitPlugin');
if (@FInitPlugin<>nil) then
try
FInitPlugin(Application.Handle);
except on E:Exception do FInitiated:=False;
end;
@FInitIBConnection:=GetProcAddress(FPluginHandle,'InitIBCon');
if (@FInitIBConnection<>nil) then
try
{
put dbHandle from my DBAcs (datamodule) MainDB (IB_Connection)
to IB_Connection in already loaded DLL
}
if Assigned(DBAcs) and (DBAcs.MainDB.Connected) then FInitIBConnection(DbAcs.MainDB.dbHandle); {- !!! -}
except on E:Exception do
begin {none} end;
end; // try
end; // if PluginHandle<>0
//........... etc ...............
end; { procedure LoadPlugin}
Try this code example:
In DLL:
===============================
Procedure InitPlugin(ApplicationHandle:THandle); stdcall;
begin
Application.Handle:=ApplicationHandle;
DM:=TDM.Create(Application); // my data module with IB_Connection
end;
Procedure InitIBCon(IBConnectionHandle:Pointer); stdcall;
begin
//-- initiate connection
DM.IB_Connection1.dbHandleShared:=IBConnectionHandle; //!!!!
{
Warning! dbHandleShared in DLL := dbHandle from host Application
}
//---------- etc....-------------------------------
end;
In your main project (host application):
======================================
type
TInitPlugin=procedure (AppHandle:THandle); stdcall;
TInitIBConnection=procedure (IBConHandle:pointer); stdcall;
var FPluginHandle:THandle; // loaded DLL handle
FInitPlugin=TInitPlugin;
FInitIBConnection=TInitIBConnection;
Procedure LoadPlugin;
begin
FPluginHandle:=LoadLibrary('MYDLLNAME.DLL'); // DLL loading
if FPluginHandle<>0 then
begin
@FInitPlugin:=GetProcAddress(FPluginHandle,'InitPlugin');
if (@FInitPlugin<>nil) then
try
FInitPlugin(Application.Handle);
except on E:Exception do FInitiated:=False;
end;
@FInitIBConnection:=GetProcAddress(FPluginHandle,'InitIBCon');
if (@FInitIBConnection<>nil) then
try
{
put dbHandle from my DBAcs (datamodule) MainDB (IB_Connection)
to IB_Connection in already loaded DLL
}
if Assigned(DBAcs) and (DBAcs.MainDB.Connected) then FInitIBConnection(DbAcs.MainDB.dbHandle); {- !!! -}
except on E:Exception do
begin {none} end;
end; // try
end; // if PluginHandle<>0
//........... etc ...............
end; { procedure LoadPlugin}
----- Original Message -----
From: itaimpaulista
To: IBObjects@yahoogroups.com
Sent: Wednesday, October 08, 2003 9:16 AM
Subject: [IBO] dbhandle Help my
Hi, Please My
I Would like of example in delphi 5 or 7 : How passes the dbhandle
detew exe and DLL
Regards
Orlando
Yahoo! Groups Sponsor
___________________________________________________________________________
IB Objects - direct, complete, custom connectivity to Firebird or InterBase
without the need for BDE, ODBC or any other layer.
___________________________________________________________________________
http://www.ibobjects.com - your IBO community resource for Tech Info papers,
keyword-searchable FAQ, community code contributions and more !
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
[Non-text portions of this message have been removed]