Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why does BDE not install with Alias? 1

Status
Not open for further replies.

delphiman

Programmer
Dec 13, 2001
422
ZA

When I use InstallSheild Limited Edition which came
with my Delphi 6 Enterprise I find that, even though
the BDE is correctly installed in
c:\Program Files\Common Files\Borland Shared\BDE
on the target machine, it fails to install an
essential Alias which is on my machine.

I have to install this by using the BDE Administrator
on the target-machine. Which I can not expect a
user to do.

Can someone please tell me how I can get around this?
 
delphiman,

Personally, I prefer to use what I call temporary aliases for this sort of thing; that is, aliases defined at the runtime from within the application itself. It's a concept borrowed from Paradox for Windows (which called them project aliases, as opposed to public aliases stored in the (IDAPI|BDE)32.CFG file).

The article on my site provides some simple discussion and sample code that may help spark an idea on how to do this most effectively in your situation.

Hope this helps...

-- Lance
 
I stand aghast at your vast genius ... :)

But please can you tell a mere mortal how to make
some sense of an Alias which I have called "StdElect" and which is related to tables
in c:\h\StdElect\Tables. (i.e.c:\h\StdElect\Tables\Ballot.db)

How would I apply this in your code below?

procedure TElectionDM.DataModuleCreate(Sender: TObject);
var
strAliasName, // name for the temporary alias
strAliasPath : string; // directory the alias points to

begin

strAliasName := trimFileExt( extractFileName( paramStr( 0 ) ) );
strAliasPath := getAppIni( 'Settings', 'DataPath', getWorkDir() + 'data\' );

with Session do
try
screen.cursor := crHourglass;

if not isAlias( strAliasName ) then
addStandardAlias( strAliasName, strAliasPath, 'Paradox' );
finally
screen.cursor := crDefault
end; // with/try
end;
 
delphiman,

In the code shown above, the alias name is the same as the program's executable file. Thus, if your program is FOO.EXE, the alias is called :FOO:. The path for the alias is either taken from an INI file called FOO.INI, if it exists and contains a DataPath setting in the [Settings] section.

If the FOO.INI doesn't exist, the code assumes DataPath should point to a DATA\ folder below the one containing FOO.EXE. This, if FOO.EXE is installed to C:\PROGRAM FILES\FOO\, then :FOO: gets defined (by default) as
C:\PROGRAM FILES\FOO\DATA.

So, you chould rewrite the above to something along these lines:

Code:
var
   strAliasName,            // name for the temporary alias
   strAliasPath  : string;  // directory the alias points to
   
begin

   strAliasName := 'StdElect';
   strAliasPath := 'c:\h\StdElect\Tables';

   with Session do
   try
      screen.cursor := crHourglass;

      if not isAlias( strAliasName ) then
         addStandardAlias( strAliasName, strAliasPath, 'Paradox' );
   finally
      screen.cursor := crDefault
   end;  // with/try
end;

Mind you, I don't like hardcoding values like that. While it can save some initial development time, I prefer to put "magic values" that can change into user-editable configuration files and then define them at run-time.

You could easily place them in the Registry (though I've seen many end-users happily edit INI files with Notepad when they were afraid to touch RegEdit because it looked too complicated), resource strings, or some other mechanism that you find easier to maintain.

My preference for .INI files also makes it easier to uninstall things; they only need to be deleted.

Hope this helps...

-- Lance
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top