Thursday, March 22, 2007

Building COM Automation Servers with Delphi 2007

Sometime around Delphi 6 and C++Builder 5 there was a change made to Automation Servers (components written as an EXE) where they would automatically register themselves. This caused all sorts of problems for Vista UAC and just wasn't the correct thing to be doing. So for Delphi 2007 the code for Automation Servers to automatically register themselves has been removed. You are now required to run your Automation Server with the /regserver option. Example: "MyAutoServer.exe /regserver".


Anonymous said...

Chris, I have a Delphi 6 automation server and am having headaches getting it to perform its automation tasks in Vista. On this topic are there any papaers you can point me to?
Russell Belding

Chris Bensen said...

Hi Russell,

What sort of problems are you experiencing? Maybe I or readers of this blog can point you to some helpful information or give you ideas on how to diagnose and debug the problem.

russellbelding said...

Hello Chris
I have solved my problem. With D6 my automation/Come servers are registered when the program is first run. This, in Vista, must be done when logged on as the super administrator. I'll copy my installation notes here, in case someone needs this help.

1. Ensure the bcdDocuments installation files are installed on a file server on the network to which this Vista PC belongs. Call this bcdDocsShare.
2. Ensure the Administrator logon is enabled. See the Enable Administrator note below if it is not enabled. Logon as the administrator. Note this is not the same as logging on as a user with administrator privileges. Logging on as the administrator gives you administrator privileges without Vista asking you for confirmation when you perform a task requiring administrator privileges.

I am guessing the reason Vista will not install the bcdDocuments automation services when the bcdDocs program is first run under an account that is not the administrator account is this installation requires administrator privileges and Vista cannot interrupt the program to seek confirmation to perform the installation.
3. From the Vista PC run the bcdDocsShare\run_bcdDocuments.exe. With the administrator privileges given to this account this program will make a directory on the Vista PC and copy all the bcdDocuments files to this directory, nominally c:\program files\bcdDocuments\.

This directory can be changed by first editing the bcdDocuments.config file as follows. In the [ClientDirectories] section insert line
For example, if you are installing to machine MyVistaBox and you want to install to folder D:\MyFolder\MySubFolder then the entry
should be present.
4. Now the files are installed in your directory on the Vista box.

Set the Security on the bcdDocuments folder so each user of this box has Modify permission. I had to check modify twice before it stuck, so double check that this setting persists.

Now log out of the administrator account and log in as each user who will be using this PC to run bcdDocuments.
Do not set any special requirements for the bcdDocuments program. In particular do not set its Privilege Level to “Run this program as an administrator” and do not set it to run in any compatibility mode.

For each user make a shortcut to the Run_bcdDocuments.exe program on the bcdDocuments file server. The user will use this program to run bcdDocuments.
Running the bcdDocuments.exe program from its location on the Vista box in the suggested configuration fails. This seems to me to be a fault in Vista. So we may find at some stage in the life of Vista, this recipe may need changing as Vista changes.

Now when bcdDocuments.exe or any other copied file is changed, when Run_bcdDocuments .exe is next run, the changed file will be copied from the file server to this Vista PC.

Enabling the built in Administrator.
Having set up a Vista PC you have at least one administrator account. Such an account is not necessarily the built in administrator account. The built in Administrator account is (as far as I know) the only administrator account that is not asked confirming questions. The Vista default is this account is hidden. To make this account available log onto any administrator account then
a. Run secpol.msc
b. Select Local Policies, then Security Options.
c. Set Accounts: Administrator account status to “Enabled”
d. Set User Account Control: Admin Approval Mode for the Built-in Administrator to “Disabled”.

With these settings You can log onto the built in Administrator account and do administrator tasks and not be asked for confirmation before each such task is attempted.

russellbelding said...

Hello again Chris.

Using the same Delphi 6 Automation Server, which runs on Vista Ok after getting it installed here, I am trying now to install it on a Win 2003 Enterprise Server and a Win 2003 Std Terminal server. The program will partly install in that most many registry entries install but something, I do not yet know what, is not installing.

Observations: A. On a clean install of the Win 2003 Server Ent. (no SPs) the program installs as normal and provides services. I have just done this.
B. On two established Win 2003 servers both with SP2, the program installs partially in that I see many registry entries, for all the interfaces, but when asked to provide services they fail.

Installation does not work on running the program nor on running it with a /regserver command line parameter. Running it with /unregserver removes all the programs registry entries (except from file lists and the like).

I do not yet know the inner workings of COM Automation servers in the registry.

Does this problem look familiar to anyone? Help appreciated ....

Russell Belding

Post a Comment