Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2007 Apr : CoCreateInstance and threads

www.cryer.info
Managed Newsgroup Archive

CoCreateInstance and threads

Subject:CoCreateInstance and threads
Posted by:"Dejan Petrovic" (dejanbng@removethis.ztbclan.com)
Date:Tue, 10 Apr 2007 14:22:55

Main application have CoInitialize on start and CoUninitialze on end.

In thread I doing something like :
if CoCreateInstance(CLSID_DirectPlayLobby, nil, CLSCTX_INPROC_SERVER,
IID_IDirectPlayLobby3A, dxRunApp) <> 0 then

and this fail.

Next step were to add CoInitialize in thread.Create ...., CoUninitialize in
Destroy.
That fail too ! And Working if CoInitialize is in start of Execute ?!?.

Questions :
- What is diference, why CoInitilize in constructor have no efect till in
execute working ok ?
- Is that ok to have CoUninitialze in destructor because I don't know is
this fail or not. Else, I shall ensure that execute always finish till end
(even terminated ?) and to do CoUnitialize at end of Execute.
- What is there wrong if I totally miss CoUnitialize ?

tnx in advance
Dejan

Replies:

www.cryer.info
Managed Newsgroup Archive