Login
`
Templates, Tools and Utilities
|
||
Add a comment to an Icetips ArticlePlease add your comments to this article.
Please note that you must provide both a name and a valid email address in order
for us to publish your comment. Comments are moderated and are not visible until they have been approved. Spam is never approved!
Back to article list Search Articles Add Comment Printer friendly Direct link COM: Uninitalizing COM objects 1 2004-01-17 -- Carl Barnes Newsgroups: softvelocity.public.clarion6
MSDN on CoInitilize says the following:
"Typically, the COM library is initialized on a thread only once. Subsequent
calls to CoInitialize or CoInitializeEx on the same thread will succeed, as
long as they do not attempt to change the concurrency model, but will return
S_FALSE. To close the COM library gracefully, each successful call to
CoInitialize or CoInitializeEx, including those that return S_FALSE, must be
balanced by a corresponding call to CoUninitialize."
When I looked an the CComInitter Destruct method it does not appear to call
CoUNinit if S_False was returned for the CoInit.
Also does CoInit really need to be called per thread? MSDN clearly says it
does, but the book "Inside COM" says per Process.
CCOMIniter.Construct procedure
code
self.hr = CoInitialize()
if self.hr = S_FALSE
self.fAlreadyInitialised = true
self.hr = S_OK
end
if self.hr = S_OK
if ~self.fAlreadyInitialised
self.fInitialised = true.
end
CCOMIniter.Destruct procedure
code
if self.fInitialised
if ~self.fAlreadyInitialised
CoUninitialize().
self.fInitialised = false
end
Today is December 3, 2024, 11:34 am This article has been viewed 35386 times. Google search has resulted in 29 hits on this article since January 25, 2004.
|
|