BDE API Examples (DbiOpenCfgInfoList)
Returns a handle to an in-memory table listing all the nodes in the configuration file accessible by the specified path.
WARNING: Be extremely careful when altering the IDAPI.CFG configuration
file. Make absolutely sure that all options and parameters are correct or corruption of the configuration
file can, and more than likely, occur.
Example 1: Retrieve a particular value from the IDAPI.CFG configuration file.
This example uses the following input:
Edit1.Text := GetConfigParameter(PARADOXLEVEL, @Count);
NOTE: Param (in this case PARADOXLEVEL) must be a string that contains the path to the node and the node item separated by a semi-colon.
At the bottom of this page are some of the more popular paths and items that are
declared as constants for use with all these examples.
function GetConfigParameter(Param: string; Count: pword): string;
var
hCur: hDBICur;
rslt: DBIResult;
Config: CFGDesc;
Path, Option: string;
Temp: array[0..255] of char;
begin
Result := ''; hCur := nil;
if Count <> nil then
Count^ := 0;
try
if Pos(';', Param) = 0 then
raise EDatabaseError.Create('Invalid parameter passed to function. There must ' +
'be a semi-colon delimited sting passed');
Path := Copy(Param, 0, Pos(';', Param) - 1);
Option := Copy(Param, Pos(';', Param) + 1, Length(Param) - Pos(';', Param));
Check(DbiOpenCfgInfoList(nil, dbiREADONLY, cfgPERSISTENT, StrPCopy(Temp, Path), hCur));
Check(DbiSetToBegin(hCur));
repeat
rslt := DbiGetNextRecord(hCur, dbiNOLOCK, @Config, nil);
if rslt = DBIERR_NONE then
begin
if StrPas(Config.szNodeName) = Option then
Result := Config.szValue;
if Count <> nil then
Inc(Count^);
end
else
if rslt <> DBIERR_EOF then
Check(rslt);
until rslt <> DBIERR_NONE;
finally
if hCur <> nil then
Check(DbiCloseCursor(hCur));
end;
end;
Example 2: Set a particular value in the IDAPI.CFG configuration file (16-Bit Only) and (32-Bit, BDE v4.51 and later).
NOTE: Do not use this procedure version if you are using BDE v4.50 and earlier (See Example 3 below)
This exmaple uses the following inupt:
SetConfigParameter(LOCALSHARE, 'TRUE')
NOTE: Param (in this case LOCALSHARE) must be a string that contains the path to the node and the node item separated by a semi-colon.
At the bottom of this page are some of the more popular paths and items that are
declared as constants for use with all these examples.
procedure SetConfigParameter(Param: string; Value: string);
var
hCur: hDBICur;
rslt: DBIResult;
Config: CFGDesc;
Path, Option: string;
Found: boolean;
Temp: array[0..255] of char;
begin
hCur := nil;
Found := False;
try
if Pos(';', Param) = 0 then
raise EDatabaseError.Create('Invalid parameter passed to function. There must ' +
'be a semi-colon delimited sting passed');
Path := Copy(Param, 0, Pos(';', Param) - 1);
Option := Copy(Param, Pos(';', Param) + 1, Length(Param) - Pos(';', Param));
Check(DbiOpenCfgInfoList(nil, dbiREADWRITE, cfgPERSISTENT, StrPCopy(Temp, Path), hCur));
repeat
rslt := DbiGetNextRecord(hCur, dbiNOLOCK, @Config, nil);
if rslt = DBIERR_NONE then
begin
if StrPas(Config.szNodeName) = Option then
begin
StrPCopy(Config.szValue, Value);
Check(DbiModifyRecord(hCur, @Config, FALSE));
Found := True;
break;
end;
end
else
if rslt <> DBIERR_EOF then
Check(rslt);
until rslt <> DBIERR_NONE;
if Found = False then
raise EDatabaseError.Create(Param + ' entry was not found in configuration file');
finally
if hCur <> nil then
Check(DbiCloseCursor(hCur));
end;
end;
Example 3: Set a particular value in the IDAPI.CFG configuration file (32-Bit Only; All Versions).
NOTE: You must use this procedure version if you are using BDE v4.50 and earlier
This exmaple uses the following inupt:
SetConfigParameter2(LOCALSHARE, 'TRUE')
NOTE: Param (in this case LOCALSHARE) must be a string that contains the path to the node and the node item separated by a semi-colon.
At the bottom of this page are some of the more popular paths and items that are
declared as constants for use with all these examples.
procedure SetConfigParameter2(Param: string; Value: string);
var
hCfg: hDBICfg;
Config: SYSConfig;
Path, Option: string;
ParamCount, I: word;
pFields, pFld: pFLDDesc;
pRecBuf, pRec: pBYTE;
Found, SelfInitialized: boolean;
rslt: DBIResult;
begin
{$Ifdef WIN32}
hCfg := nil; pFld := nil; pRec := nil; Found := False; SelfInitialized := False;
try
if Pos(';', Param) = 0 then
raise EDatabaseError.Create('Invalid parameter passed to function. There must ' +
'be a semi-colon delimited sting passed');
Path := Copy(Param, 0, Pos(';', Param) - 1);
Option := Copy(Param, Pos(';', Param) + 1, Length(Param) - Pos(';', Param));
rslt := DbiGetSysConfig(Config);
if rslt <> DBIERR_NONE then
begin
if rslt = DBIERR_NOTINITIALIZED then // Engine not initialized error...
begin
SelfInitialized := True;
DbiInit(nil);
Check(DbiGetSysConfig(Config));
end
else
Check(rslt);
end;
(* DbiOpenConfigFile is defined as such:
function DbiOpenConfigFile ( { Open/Create configuration }
pszDirPath : PChar; { Directory }
bCreate : Bool; { TRUE to create/overwrite }
var hCfg : hDBICfg { Handle to config }
): DBIResult stdcall; *)
Check(DbiOpenConfigFile(Config.szIniFile, FALSE, hCfg));
(* DbiCfgGetRecord is defined as such:
function DbiCfgGetRecord ( { Get a record }
hCfg : hDBICfg; { Config Handle/NULL }
pszCfgPath : PChar; { Path }
var iFields : Word; { Returned nbr of fields }
pfldDesc : pFLDDesc; { Field descriptors }
pRec : Pointer { Field values }
): DBIResult stdcall; *)
{ Call it without the field and record buffer to get the count... }
Check(DbiCfgGetRecord(hCfg, PChar(Path), ParamCount, nil, nil));
pFields := AllocMem(ParamCount * sizeof(FLDDesc));
pFld := pFields;
pRecBuf := AllocMem(10000);
pRec := pRecBuf;
{ Get the node values... }
Check(DbiCfgGetRecord(hCfg, PChar(Path), ParamCount, pFields, pRecBuf));
for I := 0 to ParamCount - 1 do
begin
if pFields^.szName = Option then
begin
StrPCopy(PChar(pRecBuf), Value);
(* DbiCfgModifyRecord is defines as such:
function DbiCfgModifyRecord ( { Modify a record }
hCfg : hDBICfg; { Config Handle/NULL }
pszCfgPath : PChar; { Path }
iFields : Word; { Nbr of fields }
pfldDesc : pFLDDesc; { Field descriptors }
pRec : Pointer { Data values }
): DBIResult stdcall; *)
Check(DbiCfgModifyRecord(hCfg, PChar(Path), ParamCount, pFld, pRec));
Found := True;
end;
Inc(pFields);
Inc(pRecBuf, 128);
end;
if Found = False then
raise EDatabaseError.Create(Param + ' entry was not found in configuration file');
finally
if pFld <> nil then
FreeMem(pFld);
if pRec <> nil then
FreeMem(pRec);
if hCfg <> nil then
(* DbiCloseConfigFile is defined as such:
function DbiCloseConfigFile ( { Close the config file }
var hCfg : hDBICfg; { Handle }
bSave : Bool; { To save the changes }
bDefault : Bool; { To make this file the default }
bSaveAs16 : Bool { To save as a 16-bit config file }
): DBIResult stdcall; *)
{ Close and save the config file... }
Check(DbiCloseConfigFile(hCfg, TRUE, TRUE, FALSE));
if SelfInitialized = True then
DbiExit;
end;
{$Else}
raise EDatabaseError.Create('Non supported function in 16 bit');
{$EndIf}
end;
Special pre-defined constants for use with the above exmaples
const
{ Here are the parameters used to pass into the cfg functions. These are only
a small portion of what types can be passed in. You need to call
DbiOpenCfgInfoList with '\' into pszCfgPath to get all possible options if
it is not foend below. }
{ Paradox Driver Settings... }
PARADOXNETDIR = '\DRIVERS\PARADOX\INIT\;NET DIR';
PARADOXVERSION = '\DRIVERS\PARADOX\INIT\;VERSION';
PARADOXTYPE = '\DRIVERS\PARADOX\INIT\;TYPE';
PARADOXLANGDRIVER = '\DRIVERS\PARADOX\INIT\;LANGDRIVER';
PARADOXLEVEL = '\DRIVERS\PARADOX\TABLE CREATE\;LEVEL';
PARADOXBLOCKSIZE = '\DRIVERS\PARADOX\TABLE CREATE\;BLOCK SIZE';
PARADOXFILLFACTOR = '\DRIVERS\PARADOX\TABLE CREATE\;FILL FACTOR';
PARADOXSTRICTINTEGRITY = '\DRIVERS\PARADOX\TABLE CREATE\;STRICTINTEGRITY';
{ dBASE Driver Settings... }
DBASEVERSION = '\DRIVERS\DBASE\INIT\;VERSION';
DBASETYPE = '\DRIVERS\DBASE\INIT\;TYPE';
DBASELANGDRIVER = '\DRIVERS\DBASE\INIT\;LANGDRIVER';
DBASELEVEL = '\DRIVERS\DBASE\TABLE CREATE\;LEVEL';
DBASEMDXBLOCKSIZE = '\DRIVERS\DBASE\TABLE CREATE\;MDX BLOCK SIZE';
DBASEMEMOFILEBLOCKSIZE = '\DRIVERS\DBASE\TABLE CREATE\;MEMO FILE BLOCK SIZE';
{ InterBase Driver Settings... }
INTERBASESERVERNAME = '\DRIVERS\INTRBASE\DB OPEN\;SERVER NAME';
INTERBASEUSERNAME = '\DRIVERS\INTRBASE\DB OPEN\;USER NAME';
INTERBASEOPENMODE = '\DRIVERS\INTRBASE\DB OPEN\;OPEN MODE';
INTERBASESCHEMACACHESIZE = '\DRIVERS\INTRBASE\DB OPEN\;SCHEMA CACHE SIZE';
INTERBASELANGDRIVER = '\DRIVERS\INTRBASE\DB OPEN\;LANGDRIVER';
INTERBASESQLQRYMODE = '\DRIVERS\INTRBASE\DB OPEN\;SQLQRYMODE';
INTERBASESQLPASSTHRUMODE = '\DRIVERS\INTRBASE\DB OPEN\;SQLPASSTHRU MODE';
INTERBASESCHEMACACHETIME = '\DRIVERS\INTRBASE\DB OPEN\;SCHEMS CACHE TIME';
INTERBASEMAXROWS = '\DRIVERS\INTRBASE\DB OPEN\;MAX ROWS';
INTERBASEBATCHCOUNT = '\DRIVERS\INTRBASE\DB OPEN\;BATCH COUNT';
INTERBASEENABLESCHEMACACHE = '\DRIVERS\INTRBASE\DB OPEN\;ENABLE SCHEMA CACHE';
INTERBASEENABLEBCD = '\DRIVERS\INTRBASE\DB OPEN\;ENABLE BCD';
INTERBASEBLOBSTOCACHE = '\DRIVERS\INTRBASE\DB OPEN\;BLOBS TO CACHE';
INTERBASEBLOBSIZE = '\DRIVERS\INTRBASE\DB OPEN\;BLOB SIZE';
INTERBASEVERSION = '\DRIVERS\INTRBASE\INIT\;VERSION';
INTERBASETYPE = '\DRIVERS\INTRBASE\INIT\;TYPE';
INTERBASEDLL = '\DRIVERS\INTRBASE\INIT\;DLL';
INTERBASEDRIVERFLAGS = '\DRIVERS\INTRBASE\INIT\;DRIVER FLAGS';
INTERBASEDLL32 = '\DRIVERS\INTRBASE\INIT\;DLL32';
INTERBASETRACEMODE = '\DRIVERS\INTRBASE\INIT\;TRACE MODE';
{ Oracle Driver Settings... }
ORACLEBATCHCOUNT = '\DRIVERS\ORACLE\DB OPEN\;BATCH COUNT';
ORACLEENABLEBCD = '\DRIVERS\ORACLE\DB OPEN\;ENABLE BCD';
ORACLEENABLEINTEGERS = '\DRIVERS\ORACLE\DB OPEN\;ENABLE INTEGERS';
ORACLEENABLESCHEMACACHE = '\DRIVERS\ORACLE\DB OPEN\;ENABLE SCHEMA CACHE';
ORACLELANGDRIVER = '\DRIVERS\ORACLE\DB OPEN\;LANGDRIVER';
ORACLELISTSYNONYMS = '\DRIVERS\ORACLE\DB OPEN\;LIST SYNONYMS';
ORACLEMAXROWS = '\DRIVERS\ORACLE\DB OPEN\;MAX ROWS';
ORACLENETPROTOCOL = '\DRIVERS\ORACLE\DB OPEN\;NET PROTOCOL';
ORACLEOPENMODE = '\DRIVERS\ORACLE\DB OPEN\;OPENMODE';
ORACLEROWSETSIZE = '\DRIVERS\ORACLE\DB OPEN\;ROWSET SIZE';
ORACLESCHEMACACHEDIR = '\DRIVERS\ORACLE\DB OPEN\;SCHEMA CACHE DIR';
ORACLESCHEMACACHESIZE = '\DRIVERS\ORACLE\DB OPEN\;SCHEMA CACHE SIZE';
ORACLESCHEMACACHETIME = '\DRIVERS\ORACLE\DB OPEN\;SCHEMA CACHE TIME';
ORACLESERVERNAME = '\DRIVERS\ORACLE\DB OPEN\;SERVER NAME';
ORACLESQLPASSTHRUMODE = '\DRIVERS\ORACLE\DB OPEN\;SQLPASSTHRU MODE';
ORACLESQLQUERYMODE = '\DRIVERS\ORACLE\DB OPEN\;SQLQRYMODE';
ORACLEUSERNAME = '\DRIVERS\ORACLE\DB OPEN\;USER NAME';
ORACLEDLL = '\DRIVERS\ORACLE\INIT\;DLL';
ORACLEDLL32 = '\DRIVERS\ORACLE\INIT\;DLL32';
ORACLEDRIVERFLAGS = '\DRIVERS\ORACLE\INIT\;DRIVER FLAGS';
ORACLETRACEMODE = '\DRIVERS\ORACLE\INIT\;TRACE MODE';
ORACLETYPE = '\DRIVERS\ORACLE\INIT\;TYPE';
ORACLEVENDORINIT = '\DRIVERS\ORACLE\INIT\;VENDOR INIT';
ORACLEVERSION = '\DRIVERS\ORACLE\INIT\;VERSION';
{ MSACCESS Driver Settings... }
MSACCEESSLANGDRIVER = '\DRIVERS\MSACCESS\DB OPEN\;LANGDRIVER';
MSACCESSDATABASENAME = '\DRIVERS\MSACCESS\DB OPEN\;DATABASE NAME';
MSACCESSUSERNAME = '\DRIVERS\MSACCESS\DB OPEN\;USER NAME';
MSACCESSOPENMODE = '\DRIVERS\MSACCESS\DB OPEN\;OPEN MODE';
MSACCESSSYSTEMDATABASE = '\DRIVERS\MSACCESS\DB OPEN\;SYSTEMDATABASE';
MSACCESSVERSION = '\DRIVERS\MSACCESS\INIT\;VERSION';
MSACCESSTYPE = '\DRIVERS\MSACCESS\INIT\;TYPE';
MSACCESSDLL32 = '\DRIVERS\MSACCESS\INIT\;DLL32';
MSACCESSDRIVERFLAGS = '\DRIVERS\MSACCESS\INIT\;DRIVER FLAGS';
MSACCESSTRACEMODE = '\DRIVERS\MSACCESS\INIT\;TRACE MODE';
{ System Initialization Settings... }
AUTOODBC = '\SYSTEM\INIT\;AUTO ODBC';
DATAREPOSITORY = '\SYSTEM\INIT\;DATA REPOSITORY';
DEFAULTDRIVER = '\SYSTEM\INIT\;DEFAULT DRIVER';
LANGDRIVER = '\SYSTEM\INIT\;LANGDRIVER';
LOCALSHARE = '\SYSTEM\INIT\;LOCAL SHARE';
LOWMEMORYUSAGELIMIT = '\SYSTEM\INIT\;LOW MEMORY USAGE LIMIT';
MAXBUFSIZE = '\SYSTEM\INIT\;MAXBUFSIZE';
MAXFILEHANDLES = '\SYSTEM\INIT\;MAXFILEHANDLES';
MEMSIZE = '\SYSTEM\INIT\;MEMSIZE';
MINBUFSIZE = '\SYSTEM\INIT\;MINBUFSIZE';
SHAREDMEMLOCATION = '\SYSTEM\INIT\;SHAREDMEMLOCATION';
SHAREDMEMSIZE = '\SYSTEM\INIT\;SHAREDMEMSIZE';
SQLQRYMODE = '\SYSTEM\INIT\;SQLQRYMODE';
SYSFLAGS = '\SYSTEM\INIT\;SYSFLAGS';
VERSION = '\SYSTEM\INIT\;VERSION';
Back to BDE API Reference Page