| dbHandleShared property |
Applies to
TIB_Connection
Declaration
Property dbHandleShared : isc_db_Handle;
Description
Native InterBase connection handle.
A BDE acquired handle can be assigned to this property in order to piggy
back an IB Objects IB_Connection to a BDE acquired handle. By being
shared it will not attempt to call isc_detach_database() when Disconnect
is called.
function GetNativeHandle(Database: TDatabase): Pointer;
var
length: word;
APtr: Pointer;
begin
// This is how you get a native IB handle out of a TDatabase.
APtr := nil;
if Assigned( Database ) and
Database.Connected and
( Database.DriverName = 'INTRBASE' ) then
Check( DBIGetProp( HDBIOBJ( Database.Handle ), dbNATIVEHNDL,
Addr(APtr),
SizeOf( Pointer ),
length ));
Result := APtr;
end;
procedure TfrmEvents.FormCreate(Sender: TObject);
begin
// An IB_Connection can take a raw handle from a TDatabase
dbEvents.Connected := True;
ibEvents.dbHandleShared := GetNativeHandle(dbEvents);
// Register the events to receive notification.
IB_Events.RegisterEvents;
end;
procedure TfrmEvents.FormDestroy(Sender: TObject);
begin
// Before the TDatabase closes be sure to clear the dbHandle out of the
// IB_Connection. Otherwise, it may attempt an operation after the handle
// has become invalid.
ibEvents.dbHandleShared := nil;
end; |