Link to home
Start Free TrialLog in
Avatar of pjelias
pjelias

asked on

How to set the Paradox NET DIR via code ?

I am not sure if this is the right place to put this, but will ask anyway.

I am creating an install package for a delphi app I have created, using Installshield.

I have basically got it working EXCEPT, I would like to set the NET DIR for Paradox to a directory defined by the user (or by me), it currently defaults to C:\.

What is the best way to do this, so that the NET DIR can be set during installation.


Thanks
pje
Avatar of simonet
simonet
Flag of Brazil image

Running the query below through the Borland community site I found quite a few answers that might interest you:

http://search.borland.com/query.html?qt=PARADOX+NET+DIR&qs=&qc=&pw=100%25&ws=0&la=&qm=0&st=1&nh=10&lk=1&rf=0&oq=&rq=0&col=bogus&col=nowebdsp

the most interesting was:

Technical Information Database

TI230B.txt   Changing the NET DIR Programmatically
Category   :General Programming
Platform    :All
Product    :BDE  All

Description:
General:
The "NET DIR" parameter for the Paradox driver is usually
indicated in the BDE Configuration Utility on the drivers
tab.  The NET DIR indicates where the PDOXUSRS.NET file is
located. If the NET DIR is pointing to a location not
containing a PDOXUSRS.NET file, one will be created there.

Changing the NET DIR programmatically:
It is possible to change where the NET DIR is pointing
programmatically by using the DbiSetProp() function, but
first, a handle to the BDE session must be acquired. The
session handle can be acquired through DbiGetCurrSession().
Here is how one could change the NET DIR:

void main(void)
{
     hDBISes hSes;
     
     DbiInit(NULL);
     DbiGetCurrSession(&hSes);
     DbiSetProp(hSes, sesNETFILE, (UINT32)"c:\\temp");
     Dbi...
     ...
}

Notes:
The sesNETFILE constant is an Object Property and a clearer definition can be found by searching for "Object Property" in the BDE On-Line help.  Another way to change the default  NET DIR is to pass DbiInit() a DBIEnv structure that specifies a different .cfg (configuration) file other than the default  IDAPI.CFG (calling DbiInit(NULL) will use IDAPI.CFG).  This method is not reccommended because only one configuration file can be used for all BDE applications.

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


As fas Delphi goes, the code above translates to something like:



var
  hCur : hDBICur;
  Config : CFGDesc;
  ContinueIt: boolean;

begin
  if DbiInit(nil) = DBIERR_NONE then
  begin
    hCur := nil;
    if DbiOpenCfgInfoList(nil, dbiREADWRITE, cfgPersistent,
        '\DRIVERS\PARADOX\INIT', hCur) = DBIERR_NONE then
    begin
      if DbiSetToBegin(hCur) = DBIERR_NONE then
      begin
        ContinueIt := true;
        while ContinueIt do
        begin
          if(DbiGetNextRecord(hCur, dbiWRITELOCK, @Config, nil)
                 <> DBIERR_NONE) then
            ContinueIt := false
          else
            if StrIComp(Config.szNodeName, 'NET DIR') = 0 then
            begin
              StrCopy(Config.szValue, 'C:\TEMP');
              DbiModifyRecord(hCur, @Config, true);
              ContinueIt := false
            end;
        end;
      end;
    end;
    DbiExit();
  end;
end;



Yours,

Alex
Athena's Place: http://www.bhnet.com.br/~simonet

Avatar of pjelias
pjelias

ASKER

Alex,

Looks good, (have not tested yet), but would probably prefer to change during Installation of App.

In regard to using InstallShield though, I would assume that the above would need to be run sometime during installation, so that variables can be passed to above code.

Was probably looking more for a method within InstallShield (currently using Installshield Professional - Windows Installation - Vers 2.03, or Even the InstallShield Express that comes with Delphi)



Regards
pje
ASKER CERTIFIED SOLUTION
Avatar of kretzschmar
kretzschmar
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pjelias

ASKER

kretzschmar,

tried your method above, got a message that the Directory that I specifield was controlled by another NETWORK File (The one set in the BDE)
well, this must done for all clients,
and you should try it outside the ide
(better close the ide or all datasets there))
meikl ;-)
just to say,
that the .net-location
in my sample is only a sample location
meikl ;-)
any further problems?
any results?
Avatar of pjelias

ASKER

Tried kretzschmar's suggestion, after some minor tweaking, works ok.
Avatar of pjelias

ASKER

kretzschmar,

after some minor tweaking, works ok.

Found alternate solution though via InstallShield, basically create an IDAPI.CFG file pointing to the appropriate directory, and then include this file with distributable files.

will still give you the points.

Thanks