Solved

How to set the Paradox NET DIR via code ?

Posted on 2002-04-02
10
308 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 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
 

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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

744 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now