Solved

How to set the Paradox NET DIR via code ?

Posted on 2002-04-02
10
311 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
problem when i try to pack my dll file with upx 9 72
delphi exception 7 63
FMX StringGrid1->Canvas->FillRect Problem 3 127
JAudiorecorder record freezing the app 29 60
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…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

920 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

14 Experts available now in Live!

Get 1:1 Help Now