Subject RE: [IBO] Getting Remote Computer Name
Author Anthony Tanas
">IS IT OK to ask "off topic" questions here?

As a rule, no. This list is specifically about IB Objects."

OK, won't happen again.

">This is a general Delphi question.

Borland has forums for general Delphi questions. If you're writing
installer scripts using products like InstallShield or Inno, those companies
also run forums."

I am writing my own from scratch. I have it set up the database and

"Some comments on assumptions:

>I have a two part installer for my program. The main installer is
>designed to run on the server and it sets up Firebird and then the
>database. It then installs the client installer on the server.
>So the client installer should be run on each client machine directly
>off of the server. By so doing I want to get the server name to set up
>the client so it can find the database.
>My initial version of this just got the path information (the BDE just
>wanted the relative path to the database) but of course IBObjects wants
>the absolute path on the server.

Actually, this assumption is wrong. IBO wants the absolute path on the
server because the Firebird API requires it. You simply can't use maps or
shares for connecting to databases.

When you were using the BDE, you also used the absolute path. You
configured it in your BDE setup with an alias and your VCL TDatabase
referred to the alias. In your BDE setup, your alias included the Server

Hmmm...In the BDE the path was set to something like
"server:/sharename/mydb.fdb" .

"In IBO, Server and Path are separate and you assign a Protocol. IBO
constructs it own connection string from these elements. If it resolves to
something "illegal", the API will ...


For security reasons, as well as site flexibility, you shouldn't be
hard-coding either the hostname or the path in your app."

Certainly not the host name, though currently I am hard coding the
path. But since I am creating the setup and dictating the requirements for
my system, is this really a problem? I'll change this though before I
finish my beta test.

"For the path, it is a very, very good idea to use Firebird's aliases in
your apps, in preference to the actual path. Suppose firebird.conf on your
development machine defines this alias:

MyAlias = c:\mydata\mydb.fdb

On the deployment site, the host server reserves the C-drive for software
only, and keeps databases on drive D. Then, firebird's aliases.conf's entry
there would be

MyAlias = d:\data\MyApp\mydb.fdb

Or, if the site you are deploying to runs Firebird on a Linux host, the
aliases.conf entry might be:

MyAlias = /data/myapp/mydb.fdb

Thus, there is nothing to change when you deploy your app. Your app simply
doesn't know or care."

OK, I'll definitely do this then, thank you. I understand how this
aids in flexibility, but how for security?

"Your installer needs to know where the user site wants the database to be.
This applies to BOTH the host machine and the aliases.conf. So your
installer needs to be able to find the hostname of the *DATABASE* server
(which is not necessarily going to be the same as the hostname of the
software installation server)."

Well if I specify that that is how the client install is to be done,
what would the problem be? I think it's a good idea because it minimizes
the technical information the person installing the software needs to

">How can I determine the machine name for a mapped drive (or even if
>it's a UNC path, perhaps without parsing the name out of the path

The question is irrelevant. For each specific deployment, your installer
needs to SET the server and database path, not GET them. If the installer
is a Delphi app, you would supply an ini file. How you use it depends on
how you want to do this deployment.
At the end of the day, you want to be able to
--- record/read/create the file path[s] to the database[s] and shadow[s] (if
you are shadowing)
--- create [an] alias[es] in the aliases.conf file of the DATABASE host for
this [these] paths
--- record the node name of the DATABASE host

The usual way with Delphi is to use an ini file. Whether you read from or
write to the ini file (or a mixture) depends on how you're controlling
things, e.g. insisting on hard paths for everything (not advisable, but you
can force this by hard-coding the ini file) or allowing the Responsible
Adult running the installer to input some things."

Heh...if my actual users are doing the install themselves, well they
can hardly understand their own business in many cases, so I want to
minimize their input in regards to the install. Typically I think someone
from my own company would do the installation though.

Well here is how I ended up doing it: When the server install is run it
calls GETCOMPUTERNAME and then writes the computer name into a file that I
put in the directory containing the client install that I set up on the

Then the client install is run on the client machines (off of the server)
and then can read the file and puts the computer name in the registry and
then my main program sets the TIODatabase up when it is initialized.
Currently the path is still hard coded, but I'll change that to use the
aliases as you suggest. Does this sound OK?

"There may be other things you need to make your installer do, such as
checking the %sysdir%\drivers\etc\HOSTS file for a DNS entry for the
database host, et al. Write a Delphi routine to convert the ini file
entries into Registry entries on the client (and possibly make this routine
available to be re-run in future when the hostname and/or database path
change, e.g. when moving the database server from a Windows to a Linux

Installer tools have similar capabilities."

Ok, thanks for all these suggestions. I will continue to refine my
installer during my beta test in the coming months. I'm also planning on
devising an automatic update system that works over the internet as well.

">Let me know if this is not an acceptable question to ask here.

It's not, really, since it's not IBO-specific but a general Delphi/Firebird
environment issue. There again, Delphi-specific questions aren't too
welcome on the firebird-support list (the place you go for Firebird-specific
questions). It happens to be a Saturday morning here, so I answered this
with more off-topic detail than would be acceptable normally. This is an
overt abuse of power, since I'm the moderator of this list. :-)"


I hope you had a great Saturday! Thanks for the help with everything! You
are very kind to give me the time.

BTW, I think I'm going to order the book from Amazon...I think it works out
to be $25 cheaper but mainly it will ship within 24 hours and I want it
ASAP. Is there a foundation or something I can donate the $25 difference
to? I would be happy to do that and certainly when I start making money
with my program I would be delighted to support the firebird project as I