[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to set the Paradox NET DIR via code ?

Posted on 2002-04-02
10
Medium Priority
?
358 Views
Last Modified: 2010-04-04
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
0
Comment
Question by:pjelias
  • 5
  • 4
10 Comments
 
LVL 15

Expert Comment

by:simonet
ID: 6914989
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

0
 

Author Comment

by:pjelias
ID: 6915062
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
0
 
LVL 27

Accepted Solution

by:
kretzschmar earned 300 total points
ID: 6915239
?

if you use any database in your app a default tsession-object is created (named session).

just adjust the netfiledir-property there at appstart, before opening any dataset

for example
session.netfiledir := extractfilepath(application.exename);
//sets the net-dir to the app-dir

no installation modifiers must be done

meikl ;-)
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:pjelias
ID: 6933379
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)
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6933388
well, this must done for all clients,
and you should try it outside the ide
(better close the ide or all datasets there))
meikl ;-)
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6934007
just to say,
that the .net-location
in my sample is only a sample location
meikl ;-)
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6949987
any further problems?
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6979622
any results?
0
 

Author Comment

by:pjelias
ID: 6979787
Tried kretzschmar's suggestion, after some minor tweaking, works ok.
0
 

Author Comment

by:pjelias
ID: 6979792
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
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Loops Section Overview
Screencast - Getting to Know the Pipeline
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question