 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Neil Guest
|
Posted: Fri Jan 28, 2005 10:33 am Post subject: TCom.Initialize Error |
|
|
There's been a few posts about problems with running applications that are
ole automation servers on machines where the user does not have access
rights to the registry. In TComServer.Initialize the call to UpdateRegistry
is wrapped in an except block for EOleRegistration Error:
procedure TComServer.Initialize;
begin
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;
if FStartMode in [smRegServer, smUnregServer] then Halt;
ComClassManager.ForEachFactory(Self, FactoryRegisterClassObject);
end;
Unfortunately when you have insufficient rights the line that raises an
exception is wrapped in an OleCheck:
procedure RegisterTypeLibrary(TypeLib: ITypeLib; const ModuleName: string);
var
Name: WideString;
HelpPath: WideString;
begin
Name := ModuleName;
HelpPath := ExtractFilePath(ModuleName);
OleCheck(RegisterTypeLib(TypeLib, PWideChar(Name), PWideChar(HelpPath)));
end;
This means that the actual exception raised is an EOleSysError. As
EOleSysError is not a descendent of EOleRegistrationError then the error
does not get trapped.
As this code is called during Application.Initialization (ie before the
exception handler is loaded(?)) this produces a nasty error that cannot be
suspressed or trapped.
Is this a Delphi bug? Is there anything I can do about it?
There was some suggestion on a similar posting that you could override
TAutoObjectFactory with your own implementation of UpdateRegistry but this
does help.
Thanks
|
|
| Back to top |
|
 |
Neil Guest
|
Posted: Fri Jan 28, 2005 2:58 pm Post subject: Re: TCom.Initialize Error |
|
|
| Quote: | There was some suggestion on a similar posting that you could override
TAutoObjectFactory with your own implementation of UpdateRegistry but this
does help.
|
I meant does not help
! sorry.
"Neil" <firstname (AT) ggpsystems (DOT) co.uk> wrote
| Quote: | There's been a few posts about problems with running applications that are
ole automation servers on machines where the user does not have access
rights to the registry. In TComServer.Initialize the call to
UpdateRegistry
is wrapped in an except block for EOleRegistration Error:
procedure TComServer.Initialize;
begin
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;
if FStartMode in [smRegServer, smUnregServer] then Halt;
ComClassManager.ForEachFactory(Self, FactoryRegisterClassObject);
end;
Unfortunately when you have insufficient rights the line that raises an
exception is wrapped in an OleCheck:
procedure RegisterTypeLibrary(TypeLib: ITypeLib; const ModuleName:
string);
var
Name: WideString;
HelpPath: WideString;
begin
Name := ModuleName;
HelpPath := ExtractFilePath(ModuleName);
OleCheck(RegisterTypeLib(TypeLib, PWideChar(Name),
PWideChar(HelpPath)));
end;
This means that the actual exception raised is an EOleSysError. As
EOleSysError is not a descendent of EOleRegistrationError then the error
does not get trapped.
As this code is called during Application.Initialization (ie before the
exception handler is loaded(?)) this produces a nasty error that cannot be
suspressed or trapped.
Is this a Delphi bug? Is there anything I can do about it?
There was some suggestion on a similar posting that you could override
TAutoObjectFactory with your own implementation of UpdateRegistry but this
does help.
Thanks
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|