BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

TCom.Initialize Error

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OLE Automation
View previous topic :: View next topic  
Author Message
Neil
Guest





PostPosted: Fri Jan 28, 2005 10:33 am    Post subject: TCom.Initialize Error Reply with 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
Neil
Guest





PostPosted: Fri Jan 28, 2005 2:58 pm    Post subject: Re: TCom.Initialize Error Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OLE Automation All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.