📄 dbiopencfginfolist.html
字号:
<HTML>
<HEAD>
<TITLE>BDE API Examples (DbiOpenCfgInfoList)</TITLE>
<META NAME="KEYWORDS" CONTENT="BDE, Borland">
<META NAME="DESCRIPTION" CONTENT="">
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#000000" ALINK="#999999" VLINK="#666666">
<CENTER>
<TABLE CELLPADDING="4" CELLSPACING="4" BORDER="0" WIDTH="600">
<TR>
<TD ALIGN="CENTER" VALIGN="TOP" COLSPAN="1"><NOBR><A HREF="/"><IMG SRC="/images/bolus.gif" ALT="[View Borland Home Page]" BORDER="0"></A><A HREF="/products.html"><IMG SRC="/images/products.gif" ALT="[View Product List]" BORDER="0"></A><A HREF="/searchsite/"><IMG SRC="/images/search.gif" ALT="[Search This Web Site]" BORDER="0"></A><A HREF="/download.html"><IMG SRC="/images/downloads.gif" ALT="[View Available Downloads]" BORDER="0"></A><A HREF="/membership.html"><IMG SRC="/images/membership.gif" ALT="[Join Borland Online]" BORDER="0"></A><A HREF="/newsgroups/"><IMG SRC="/images/newsgroups.gif" ALT="[Enter Discussion Area]" BORDER="0"></A><A HREF="/feedback/"><IMG SRC="/images/feedback.gif" ALT="[Send Email To Webmaster]" BORDER="0"></A></NOBR></TD>
</TR>
<TR>
<TR><TD ALIGN="LEFT" VALIGN="TOP" COLSPAN="1"><font size=2>
<h2>BDE API Examples (DbiOpenCfgInfoList)</h2>
Returns a handle to an in-memory table listing all the nodes in the configuration file accessible by the specified path.
<hr size=2 noshade>
<B>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.</B>
<hr size=2 noshade>
<H3>Example 1: Retrieve a particular value from the IDAPI.CFG configuration file.</H3>
This example uses the following input:<BR>
<I>Edit1.Text := GetConfigParameter(PARADOXLEVEL, @Count);</I><BR>
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 <A HREF="#Bottom">bottom of this page</A> are some of the more popular paths and items that are
declared as constants for use with all these examples.
<PRE>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;</PRE>
<!-- SF -->
<HR SIZE=2 NOSHADE>
<H3>Example 2: Set a particular value in the IDAPI.CFG configuration file (16-Bit Only) and (32-Bit, BDE v4.51 and later).</H3>
<H4>NOTE: Do not use this procedure version if you are using BDE v4.50 and earlier (See Example 3 below)</H4>
This exmaple uses the following inupt:
<I>SetConfigParameter(LOCALSHARE, 'TRUE')</I><BR>
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 <A HREF="#Bottom">bottom of this page</A> are some of the more popular paths and items that are
declared as constants for use with all these examples.
<PRE>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;</PRE>
<!-- SF -->
<HR SIZE=2 NOSHADE>
<H3>Example 3: Set a particular value in the IDAPI.CFG configuration file (32-Bit Only; All Versions).</H3>
<H4>NOTE: You must use this procedure version if you are using BDE v4.50 and earlier</H4>
This exmaple uses the following inupt:
<I>SetConfigParameter2(LOCALSHARE, 'TRUE')</I><BR>
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 <A HREF="#Bottom">bottom of this page</A> are some of the more popular paths and items that are
declared as constants for use with all these examples.
<PRE>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 }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -