Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to modify the idapi.cfg settings through code part II Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
Modify the idapi.cfg settings through code part II 28-Oct-02
Category
BDE
Language
Delphi 2.x
Views
190
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			 
Title: 
Author: Jonas Bilinkevicius
Product: Delphi 2.x (or higher)
Post Date: 10/28/2002

Problem/Question/Abstract:

How can my program access the idapi.cfg file and probably change its INIT (Local 
Share etc.) section?

Answer:

For 32bit only. You can of course use the registry to determine the default CFG 
File instead of passing it as a parameter here:
1   
2   procedure ModifyCFG(const ACFGFile, AValue, AEntry, ACFGPath: string; SaveAsWin31:
3     bool);
4   var
5     hCfg: hDBICfg;
6     pRecBuf, pTmpRec: pByte;
7     pFields: pFLDDesc;
8     Count: word;
9     i: integer;
10    Save: boolean;
11    Reg: TRegistry;
12  const
13    RegSaveWIN31: array[bool] of string = ('WIN32', 'WIN31');
14  begin
15    hCfg := nil;
16    pFields := nil;
17    pRecBuf := nil;
18    Save := False;
19    Check(DbiOpenConfigFile(PChar(ACFGFile), False, hCfg));
20    try
21      Check(DbiCfgPosition(hCfg, PChar(ACfgPath))); {neccessary...?}
22      Check(DbiCfgGetRecord(hCfg, PChar(ACfgPath), Count, nil, nil));
23      pRecBuf := AllocMem(succ(Count) * 128); {128 additional safety...}
24      pFields := AllocMem(Count * sizeof(FLDDesc));
25      Check(DbiCfgGetRecord(hCfg, PChar(ACfgPath), Count, pFields, pRecBuf));
26      for i := 1 to Count do
27      begin
28        if StrPas(pFields^.szName) = AEntry then
29        begin
30          pTmpRec := pRecBuf;
31          Inc(pTmpRec, 128 * (i - 1));
32          StrPCopy(PChar(pTmpRec), AValue);
33        end;
34        inc(pFields);
35      end;
36      dec(pFields, Count);
37      Check(DbiCfgModifyRecord(hCfg, PChar(ACfgPath), Count, pFields, pRecBuf));
38      Save := True;
39    finally
40      if hCfg <> nil then
41        Check(DbiCloseConfigFile(hCfg, Save, True, SaveAsWin31));
42      if pRecBuf <> nil then
43        FreeMem(pRecBuf, succ(Count) * 128);
44      if pFields <> nil then
45        FreeMem(pFields, Count * sizeof(FLDDesc));
46    end;
47    {update registry SAVECONFIG value}
48    Reg := TRegistry.Create;
49    try
50      Reg.RootKey := HKEY_LOCAL_MACHINE;
51      if not Reg.OpenKey('SOFTWARE\Borland\Database Engine', False) then
52        ShowMessage('Configuration Path not found')
53      else
54      begin
55        Reg.LazyWrite := False;
56        Reg.WriteString('SAVECONFIG', RegSaveWIN31[SaveAsWin31]);
57        Reg.CloseKey;
58      end;
59    finally
60      Reg.Free;
61    end;
62    {DbiExit/Init to re-read cfg... make absolutely sure there are no active 
63  	DB components when doing this (it's is best done by a loader app)}
64    Session.Close;
65    Session.Open;
66  end;



			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC