Solved

How to set the Paradox NET DIR via code ?

Posted on 2002-04-02
10
325 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 100 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Dev Express grid collapse 2 47
creating threads in delphi 1 164
Find and Replace Stream with 0s 8 73
Firemonkey android show image from resource ? 1 56
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

733 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