Using an alternative idapi.cfg file

Using an alternative idapi.cfg file

Post by Stone » Sat, 29 Jun 1996 04:00:00



I have a DB application written in Delphi (16 bit) which is using the BDE
to access Paradox for Windows tables on a LAN.  I want to distribute this
to users on the LAN but I don't want to have to change the local idapi.cfg
file on each workstation to include the aliases used by the prog.  In the
past I have delivered apps using Paradox for Windows in a similar way by
using a Paradox command line switch to use a different idapi.cfg located
on a common network server which has all the aliases defined.  But I
havn't been able to get the Delphi app. to use anything other than the
file specified in the CONFIGFILE01 item in the IDAPI topic of the win.ini
file.

Is there a way for me to specify an alternative idapi.cfg in my Delphi
code?

Delphi's help refers to direct calls to the BDE using procedures declared
in the dbiprocs.pas and dbitypes.pas units and mentions the BDE Users
Guide.  Is this what I should be looking at?  Is there anywhere I can get
hold of this reference on-line?

My systems are all running under Windows 3.11 on a Novell LAN.

Grateful for any suggestions

--------------------------------------------------------------------------
--------------

--------------------------------------------------------------------------
--------------

 
 
 

Using an alternative idapi.cfg file

Post by Tanel Hi » Sat, 13 Jul 1996 04:00:00


[snip]
: Is there a way for me to specify an alternative idapi.cfg in my Delphi
: code?

[snip]

hope it helps!

Tanel
------
{*
**  Example how to use alternative BDE configuration file in Delphi
**  by Tanel Hiir 1996
**
**  Usage:
**    Add this unit as _first_ unit (or at least very beginning) 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 = '';       { 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.

 
 
 

Using an alternative idapi.cfg file

Post by Tanel Hi » Sun, 14 Jul 1996 04:00:00


: {*
: **  Example how to use alternative BDE configuration file in Delphi
: **  by Tanel Hiir 1996
: **

Hello again,

I forgot to add some comments about example...

If you try to run this example under Delphi with different idapi.cfg file
as Delphi uses then you will get exception "cannot initialize with
different configuration file" or something similar.

BDE is unable to use two different configuration files same time (ie, one
application uses c:\idapi\idapi.cfg and other x:\newidapi.cfg 4 exmple)
and refuses to initilize when finds itself already from memory.

Therefore yu have to close delhi before you test your alternative config
file. :-( And does not let you to run two programs with different
configuration files at the same time.

Sometimes when application terminates incorrectly BDE dll-s remain in
memory. Then you can get same exception if your application uses different
idapi.cfg as terminated application. Rebooting windows helps .. but there
is simpler way  - look for nice program killdlph by Rolf Frei from delphi
super page - it removes also idapi dll-s and you don't have to reboot
anymore (kldlph12.zip from 16bit freeware apps w/ sources page).

tanel

 
 
 

1. alternative idapi.cfg file

Greetings,
Does anyone know if it is possible to cause a Delphi app, at runtime, to
use a BDE config file other than the one identified in the WIN.INI file?

In WIN.INI the IDAPI section looks like this:
[IDAPI]
DLLPATH=D:\DELPHI\IDAPI
CONFIGFILE01=D:\DELPHI\IDAPI\IDAPI.CFG

I want to be able to have several BDE config files and override the use
of the default one on the fly.  Ever done that?  Thanks in advance for
any help.
--
Graham Farquharson
Advantage Energy Services Ltd
Calgary, Canada


2. Your Opinion on Learningtree Oracle data warehouse course

3. ALIAS IN idapi.cfg AND PDOXWORK.CFG

4. FoxPro 2.6 Questions

5. Using alternate IDAPI.CFG with an app

6. Error 3170 Couldn't find installable ISAM

7. Help! Multiple idapi.cfg files

8. Adding and deleting ODBC drivers in the IDAPI.CFG at run time

9. How to modify the IDAPI.CFG

10. DELPHI 1 : Deployement of SQL Links application without IDAPI.CFG

11. idapi.cfg

12. Changing IDAPI.CFG does not affect Paradox Table behavior