Subject | Using Firebird client with IBO |
---|---|
Author | Salvatore Besso |
Post date | 2005-04-25T20:35:16Z |
hello all,
due to frequent questions about how to use Firebird client with IBO, I'd
like to share this small unit that I've made for my programs. Be sure to
include this unit as the *FIRST* unit in the uses clause of your project
(.dpr file). It has also two handy initialized variables that contain the
Firebird root and Firebird bin folder. It works only with Firebird 1.5 or
later.
Regards
Salvatore
-------------------------------
unit IB_SetLibFb15;
interface
var
FirebirdRoot: string = '';
FirebirdBin: string = '';
implementation
uses
Windows,
IB_Constants;
function GetNewClientPathAndName: AnsiString;
{ don't localize anything into this procedure! }
const
FBRoot = 'SOFTWARE\Firebird Project\Firebird Server\Instances';
FBValue = 'DefaultInstance';
FBBin = 'bin\';
FBClient = 'fbclient.dll';
var
RegResult: Integer;
RegKey: HKEY;
RegKind, DataSize, Size: DWORD;
Buffer: Pointer;
begin
Result := '';
RegResult := RegOpenKeyEx(HKEY_LOCAL_MACHINE, PAnsiChar(FBRoot), 0,
KEY_READ, RegKey);
if RegResult = ERROR_SUCCESS then
try
RegResult := RegQueryValueEx(RegKey, PAnsiChar(FBValue), nil, @RegKind,
nil, @DataSize);
if (RegResult = ERROR_SUCCESS) and (RegKind = REG_SZ) then
begin
Size := DataSize;
GetMem(Buffer, DataSize);
try
RegResult := RegQueryValueEx(RegKey, PAnsiChar(FBValue), nil,
@RegKind, Buffer, @Size);
if (RegResult = ERROR_SUCCESS) and (Size <= DataSize) then
begin
SetString(FirebirdRoot, PAnsiChar(Buffer), DataSize div
SizeOf(AnsiChar) - 1);
FirebirdBin := FirebirdRoot + FBBin;
Result := FirebirdBin + FBClient
end
finally
FreeMem(Buffer)
end
end
finally
RegCloseKey(RegKey)
end
end;
initialization
{ Replace gds32.dll with the alternative client DLL name }
IB_Constants.IB_GDS32 := GetNewClientPathAndName
end.
due to frequent questions about how to use Firebird client with IBO, I'd
like to share this small unit that I've made for my programs. Be sure to
include this unit as the *FIRST* unit in the uses clause of your project
(.dpr file). It has also two handy initialized variables that contain the
Firebird root and Firebird bin folder. It works only with Firebird 1.5 or
later.
Regards
Salvatore
-------------------------------
unit IB_SetLibFb15;
interface
var
FirebirdRoot: string = '';
FirebirdBin: string = '';
implementation
uses
Windows,
IB_Constants;
function GetNewClientPathAndName: AnsiString;
{ don't localize anything into this procedure! }
const
FBRoot = 'SOFTWARE\Firebird Project\Firebird Server\Instances';
FBValue = 'DefaultInstance';
FBBin = 'bin\';
FBClient = 'fbclient.dll';
var
RegResult: Integer;
RegKey: HKEY;
RegKind, DataSize, Size: DWORD;
Buffer: Pointer;
begin
Result := '';
RegResult := RegOpenKeyEx(HKEY_LOCAL_MACHINE, PAnsiChar(FBRoot), 0,
KEY_READ, RegKey);
if RegResult = ERROR_SUCCESS then
try
RegResult := RegQueryValueEx(RegKey, PAnsiChar(FBValue), nil, @RegKind,
nil, @DataSize);
if (RegResult = ERROR_SUCCESS) and (RegKind = REG_SZ) then
begin
Size := DataSize;
GetMem(Buffer, DataSize);
try
RegResult := RegQueryValueEx(RegKey, PAnsiChar(FBValue), nil,
@RegKind, Buffer, @Size);
if (RegResult = ERROR_SUCCESS) and (Size <= DataSize) then
begin
SetString(FirebirdRoot, PAnsiChar(Buffer), DataSize div
SizeOf(AnsiChar) - 1);
FirebirdBin := FirebirdRoot + FBBin;
Result := FirebirdBin + FBClient
end
finally
FreeMem(Buffer)
end
end
finally
RegCloseKey(RegKey)
end
end;
initialization
{ Replace gds32.dll with the alternative client DLL name }
IB_Constants.IB_GDS32 := GetNewClientPathAndName
end.