IDAPI Configuration Reference

IDAPI Configuration Reference

Post by Leonid Schavele » Wed, 13 Nov 1996 04:00:00



Hi Timothy, you wrote once:

Quote:>I have a situation where a client has developed several Paradox
>applications (which of course use IDAPI).  They strongly desire that
>the existing IDAPI.CFG file description not be altered in any way,
>which of course leaves me in a tight situation.  Currently, my kludgy
>solution is to grab the win.ini file, alter it to point to my
>idapi.cfg, then alter it back to its' original state after the
>application terminates.  This works fine, unless my application
>happens to hang somewhere along the line.

Works fine, you say? I wonder how do you manage to do this.
I tried to do the same (changing win.ini when my program start),
but in vain. When any Delphi application begin to work,
IDAPI configuration becomes loaded into memory, so after
program start I can change only the string in the win.ini file:

CONFIGFILE01=C:\NewPath\NewCfg.CFG

instead of

CONFIGFILE01=C:\IDAPI\IDAPI.CFG

But this changing will have no effect, because IDAPI is already
in memory up to the moment with its old configuration tunings.

So my question is: how do you solve this problem?
The logic says, that there must be a way to force
IDAPI to reload the configuration parameters at run-time,
and you know this way. Please explain it.
Best regards.
--
Leonid Schavelev.
Ivanovo, RUSSIA.
http://www.polytech.ivanovo.su/~leonid

 
 
 

IDAPI Configuration Reference

Post by Tanel Hi » Wed, 13 Nov 1996 04:00:00


: Hi Timothy, you wrote once:
:
: >I have a situation where a client has developed several Paradox
: >applications (which of course use IDAPI).  They strongly desire that
: >the existing IDAPI.CFG file description not be altered in any way,
: >which of course leaves me in a tight situation.  Currently, my kludgy
: >solution is to grab the win.ini file, alter it to point to my
: >idapi.cfg, then alter it back to its' original state after the
: >application terminates.  This works fine, unless my application
: >happens to hang somewhere along the line.
:
: Works fine, you say? I wonder how do you manage to do this.
: I tried to do the same (changing win.ini when my program start),
: but in vain. When any Delphi application begin to work,

<snip>

Hi,

maybe following BDE initialisation code can help you both.
note, that when your app terminates incorrectly, idapi may stay in memory
and you cannot have two idapi-s in memory with differenc configuration
file.

tanel
-------------
bdeinit.pas
-------------
{*
**  Example how to use alternative BDE configuration file in Delphi
**  by Tanel Hiir 1996
**
**  Usage:
**    Add this unit as _first_ unit (before _any_ db* unit or unit using
**    db* units) in uses clause in project (.dpr) file.
**
**  Notes:
**    Tested only with Delphi 1.
**    Do _not_ add here any unit what uses db unit.
*}
unit BdeInit;

interface

implementation

uses
  Sysutils, dbiErrs,
  {$ifndef win32}
  dbiProcs, dbiTypes;
  {$else}
  bde;
  {$endif}

const
  c_IDAPCFG = 'C:\IDAPI\IDAPI.CFG'; { Fully qualified cfg file name }
  c_CLIENT = 'TANEL';  { Client name (used in lock files?) }
  c_WORKDIR = '';      { Working directory }
  c_LOCALINIT = FALSE; { True - disable network init }
  c_LANG = '0009';     { Primary language ID (BDE messages and QBE keywords) }

{
  Language ID-s from WIN32
  Danish     0006
  English    0009
  French     000c
  German     0007
  Italian    0010
  Norwegian  0014
  Portuguese 0016
  Spanish    000a
  Swedish    001d

  Language ID is actually stored in .exe as resource string
  with id SIDAPILangID (defined in dbconsts unit)
  You can use LoadStr(SIDAPILangID) to get it

  I have got only English messages out :-(
  (I have only C:\IDAPI\IDR10009.DLL not IDR10016.DLL .. )

Quote:}

var
  Env: DbiEnv;
  Err: DBIResult;
  ErrStr: array[0..255] of Char;

procedure unInitBDE; export;
begin
  dbiExit;
end;

initialization
{$ifndef win32}
  AddExitProc( unInitBDE );
{$endif}

  FillChar(Env, SizeOf(Env), 0);
  with Env do begin
    StrPCopy(szWorkDir, c_WORKDIR );
    StrPCopy(szIniFile, c_IDAPCFG );
    StrPCopy(szLang, c_LANG );
    StrPCopy(szClientName, c_CLIENT );
    bForceLocalInit := c_LOCALINIT;
  end;

  if Err <> DBIERR_NONE then
    if DbiGetErrorString(Err, ErrStr) <> DBIERR_NONE then
      raise Exception.Create( 'BDE init failed :-(  Code :' + IntToStr(Err))
    else
      raise Exception.Create( 'BDE init failed: ' + StrPas(ErrStr));

{$ifdef win32}
finalization
  unInitBDE;
{$endif}
end.

 
 
 

1. IDAPI Configuration Reference

Can anyone offer suggestions on the following:

The installation of Delphi, and corresponding BDE creates an entry in
the WIN.INI similar to the following:

[IDAPI]
CONFIGFILE01=C:\IDAPI\IDAPI.CFG

... which of course is the location of the idapi.cfg file containing
database alias information etc.  

The problem I am having is that I have two distinct idapi
configurations, and I want to point to one or the other at run time.
Does anyone know how, or if it is possible, to code an application to
directly reference an alternate idapi.cfg ie:

... I would like to have something like the following in my WIN.INI:

[IDAPI]
CONFIGFILE01=C:\IDAPI\IDAPI.CFG
CONFIGFILE02=C:\IDAPI\TESTER.CFG

and be able to tell my application at run time which idapi config file
to look at.  Any suggestions would be appreciated.

Timothy Dahm.

2. Stored Procedure with Parameters/Forward Only Cursor

3. BUGS idapi BUGS idapi BUGS idapi BUGS

4. Some BackUp & Recovery Questions

5. Problems with Ingres and BDE configuration - idapi.cfg (1/1)

6. replication permissions problem

7. Progress Newbee

8. Lotus Notes ODBC and BDE IDAPI Configuration

9. IDAPI configuration and record locking

10. Idapi configuration error

11. IDAPI configuration for multiple users...

12. Problems with Ingres and BDE configuration - idapi.cfg (0/1)