Click here to Skip to main content
15,891,863 members
Home / Discussions / COM
   

COM

 
QuestionError In Building simple ATL application Pin
maharaja pandian23-Feb-06 1:49
maharaja pandian23-Feb-06 1:49 
AnswerRe: Error In Building simple ATL application Pin
toxcct23-Feb-06 2:13
toxcct23-Feb-06 2:13 
AnswerRe: Error In Building simple ATL application Pin
Stephen Hewitt23-Feb-06 19:20
Stephen Hewitt23-Feb-06 19:20 
QuestionCOM Server in VB Pin
Anil_vvs23-Feb-06 0:01
Anil_vvs23-Feb-06 0:01 
AnswerRe: COM Server in VB Pin
Anil_vvs23-Feb-06 0:05
Anil_vvs23-Feb-06 0:05 
AnswerRe: COM Server in VB Pin
Lim Bio Liong24-Feb-06 23:38
Lim Bio Liong24-Feb-06 23:38 
QuestionGet serious trouble in Powerpoint automation code Pin
Zhaohui Xing (Joey)22-Feb-06 16:30
Zhaohui Xing (Joey)22-Feb-06 16:30 
QuestionHow to correctly use CoInitialize? Pin
Waldermort22-Feb-06 3:34
Waldermort22-Feb-06 3:34 
It's my understanding that for every call to CoInitialize() you need a call to CoUninitialize(), at least that's my interpretation of the documents on MSDN. Please look at my code:
cParse::cParse()<br />
{<br />
	try<br />
	{<br />
		CoInitialize(NULL); /** 1 **/<br />
		short vi = 1;<br />
		xls.CreateInstance(__uuidof(clsXL));<br />
		xls->Visible(&vi);<br />
	} catch(_com_error &e) {<br />
		bstrDesc = e.Description();<br />
		MessageBox(NULL,_com_util::ConvertBSTRToString(bstrDesc),0,0);<br />
	}<br />
//	CoUninitialize(); /** 2 **/<br />
}<br />
<br />
cParse::~cParse()<br />
{<br />
	try<br />
	{<br />
		CoInitialize(NULL); /** 3 **/<br />
		xls->QuitAll();<br />
	} <br />
	catch(_com_error &e) {<br />
		bstrDesc = e.Description();<br />
		MessageBox(NULL,_com_util::ConvertBSTRToString(bstrDesc),0,0);<br />
	}<br />
	CoUninitialize(); /** 4 **/<br />
}


If I use it any other way the program crashes. I'm not sure if what I have done is right or wrong (it works), but I would like a better understanding? The commented numbers are to make any replies easier to understand Big Grin | :-D
AnswerRe: How to correctly use CoInitialize? Pin
Milton Karimbekallil22-Feb-06 5:42
Milton Karimbekallil22-Feb-06 5:42 
GeneralRe: How to correctly use CoInitialize? Pin
Waldermort22-Feb-06 15:19
Waldermort22-Feb-06 15:19 
GeneralRe: How to correctly use CoInitialize? Pin
User 21559722-Feb-06 21:51
User 21559722-Feb-06 21:51 
GeneralRe: How to correctly use CoInitialize? Pin
Rory Solley22-Feb-06 21:58
Rory Solley22-Feb-06 21:58 
GeneralRe: How to correctly use CoInitialize? Pin
Waldermort23-Feb-06 1:37
Waldermort23-Feb-06 1:37 
GeneralRe: How to correctly use CoInitialize? Pin
Waldermort23-Feb-06 1:41
Waldermort23-Feb-06 1:41 
QuestionPassing interface as parameters of functions Pin
nripun21-Feb-06 23:51
nripun21-Feb-06 23:51 
AnswerRe: Passing interface as parameters of functions Pin
Malli_12322-Feb-06 0:03
Malli_12322-Feb-06 0:03 
GeneralRe: Passing interface as parameters of functions Pin
nripun22-Feb-06 1:02
nripun22-Feb-06 1:02 
Questionhow to get the selected files name during Drag&Drop's mouse moving process Pin
welli21-Feb-06 21:28
welli21-Feb-06 21:28 
QuestionIE Toolbar (Toolband) Pin
vaughandaly21-Feb-06 20:49
vaughandaly21-Feb-06 20:49 
QuestionIDispatch and bookmarks in word Pin
lparsonson21-Feb-06 4:37
lparsonson21-Feb-06 4:37 
QuestionConnecting to a running IE COM instances. Pin
TClarke21-Feb-06 3:42
TClarke21-Feb-06 3:42 
QuestionAccess violation in ADODB::Connection Pin
Dyrl20-Feb-06 7:13
Dyrl20-Feb-06 7:13 
AnswerRe: Access violation in ADODB::Connection Pin
lparsonson21-Feb-06 4:35
lparsonson21-Feb-06 4:35 
GeneralRe: Access violation in ADODB::Connection Pin
Dyrl21-Feb-06 8:48
Dyrl21-Feb-06 8:48 
GeneralRe: Access violation in ADODB::Connection Pin
lparsonson21-Feb-06 22:39
lparsonson21-Feb-06 22:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.