* Alf P. Steinbach:
* George:
Thanks Alf,
1.
I have to set manually ole32!CoInitialize, or else if I only type
CoInitialize, WinDbg will think the function resides in Kernel32.dll,
and will never stop on the breakpoint, even if it is called.
Do you think it is a bug of WinDbg?
I think you're concentrating on entirely the wrong thing.
2.
"You don't want to call CoInitialize/CoUninitialize locally anywhere,
because that doesn't work with e.g. Internet Explorer machinery." and
"Don't rely on any local calls." -- could you say the comments in some
other words please? Sorry, my English is not good.
Here is bad code, relying on local COM initialization:
void doAnHTMLDialog()
{
if( !SUCCEEDED( CoInitialize() ) )
{
throwX( "Unable to initalize COM" );
}
// Do HTML dialog using COM-based IE machinery, then
CoUninitialize();
// Dontcha know, there might still be some thread using COM! Splat!
}
int main()
{
doAnHTMLDialog();
// Perhaps do other things here, then:
return EXIT_SUCCESS;
}
Here is less bad code, which might even be counted as good if one
ignores exception safety aspects and lack of abstraction and reusability:
void doAnHTMLDialog()
{
HRESULT const initResult = CoInitialize();
if( FAILED( initResult ) )
{
throwX( "Unable to initalize COM" );
}
else if( initResult != S_OK )
A: Because it messes up the order in which people normally read text.
A: Top-posting.