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
> 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
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.
> 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.
This was changed in a recent version of Delphi IIRC, because
it caused problems when running in a non-admin account.
cheers,
Chris
> 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
The error is unfortunately not ignored, because on Vista the raised
exception is not EOleRegistrationError.
Robert