Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ComServer.UpdateRegistry question

128 views
Skip to first unread message

Francois PIETTE [ICS - MidWare]

unread,
Jul 26, 2008, 1:13:43 AM7/26/08
to
Hi !

I like to have my application offering COM services to register itself
without user intervention.
Is there any issue calling "ComServer.UpdateRegistry(TRUE);" each time the
application starts ?
I've done it and do not see any adverse effect. But then I wonder why it is
not always done and only called when the application is invoked with command
line argument "/regserver".

--
francoi...@overbyte.be
The author of the freeware multi-tier middleware MidWare
The author of the freeware Internet Component Suite (ICS)
http://www.overbyte.be

Marc Rohloff [TeamB]

unread,
Jul 28, 2008, 8:57:15 AM7/28/08
to
On Sat, 26 Jul 2008 07:13:43 +0200, Francois PIETTE [ICS - MidWare]
wrote:

> Is there any issue calling "ComServer.UpdateRegistry(TRUE);" each time the
> application starts ?

This already seems to be the case. Look at the source code for the
TComServer.Initialize method.

--
Marc Rohloff [TeamB]
marc -at- marc rohloff -dot- com

Francois PIETTE [ICS - MidWare]

unread,
Jul 28, 2008, 12:11:34 PM7/28/08
to
>> Is there any issue calling "ComServer.UpdateRegistry(TRUE);" each time
>> the
>> application starts ?
>
> This already seems to be the case. Look at the source code for the
> TComServer.Initialize method.

I don't think so. If you don't explicitely call
"ComServer.UpdateRegistry(TRUE);" at program startup, then you have to use
"/regserver" on the command line (or from Delphi's Execute menu) otherwise
the com server is not registered.

Marc Rohloff [TeamB]

unread,
Jul 28, 2008, 1:03:07 PM7/28/08
to
On Mon, 28 Jul 2008 18:11:34 +0200, Francois PIETTE [ICS - MidWare]
wrote:

> I don't think so. If you don't explicitely call

> "ComServer.UpdateRegistry(TRUE);" at program startup, then you have to use
> "/regserver" on the command line (or from Delphi's Execute menu) otherwise
> the com server is not registered.

<Delphi 7>

The initialization section in ComServ.pas calls InitComServer which
calls ComServer.Initialize which in turn calls
UpdateRegistry(FStartMode <> smUnregServer)

So unless you are unregistering you will call UpdateRegistry(true)

Francois PIETTE [ICS - MidWare]

unread,
Jul 28, 2008, 1:52:10 PM7/28/08
to
>> I don't think so. If you don't explicitely call
>> "ComServer.UpdateRegistry(TRUE);" at program startup, then you have to
>> use
>> "/regserver" on the command line (or from Delphi's Execute menu)
>> otherwise
>> the com server is not registered.
>
> <Delphi 7>
>
> The initialization section in ComServ.pas calls InitComServer which
> calls ComServer.Initialize which in turn calls
> UpdateRegistry(FStartMode <> smUnregServer)
>
> So unless you are unregistering you will call UpdateRegistry(true)

I'm using Delphi 2007. I've setup a breakpoint in UpdateRegistry. It is
/not/ called when you run the program unless you add "/regserver" to the
command line. I've checked with the old Delphi 7, and yes, with Delphi 7
UpdateRegistry is called even if "/regserver" is not on the command line.

Thanks.

Chris Morgan

unread,
Jul 29, 2008, 5:00:44 PM7/29/08
to

> I'm using Delphi 2007. I've setup a breakpoint in UpdateRegistry. It is
> /not/ called when you run the program unless you add "/regserver" to the
> command line. I've checked with the old Delphi 7, and yes, with Delphi 7
> UpdateRegistry is called even if "/regserver" is not on the command line.
>

This was changed in a recent version of Delphi IIRC, because
it caused problems when running in a non-admin account.

cheers,

Chris

Marc Rohloff [TeamB]

unread,
Jul 29, 2008, 5:46:49 PM7/29/08
to
On Tue, 29 Jul 2008 22:00:44 +0100, Chris Morgan wrote:

> This was changed in a recent version of Delphi IIRC, because
> it caused problems when running in a non-admin account.

I went and checked and D2007 only runs the code when the command
parameter is passed so it did change somewhere in between.

In Delphi 7 the code looks like this:

try
UpdateRegistry(FStartMode <> smUnregServer);
except
on E: EOleRegistrationError do
// User may not have write access to the registry.
// Squelch the exception unless we were explicitly
//told to register.
if FStartMode = smRegServer then raise;
end;

So the error should be ignored when running in an Admin account unless
it was started with /regserver

Robert Jordan

unread,
Aug 15, 2008, 3:59:05 PM8/15/08
to

The error is unfortunately not ignored, because on Vista the raised
exception is not EOleRegistrationError.

Robert

0 new messages