I never have a problem with CoInitializeEx myself, after reading MSDN it says:
Return Values<br />
This function supports the standard return values E_INVALIDARG, E_OUTOFMEMORY, and E_UNEXPECTED, as well as the following: <br />
S_OK <br />
The COM library was initialized successfully on the calling thread. <br />
S_FALSE <br />
The COM library is already initialized on the calling thread. <br />
RPC_E_CHANGED_MODE<br />
<br />
A previous call to CoInitializeEx specified a different concurrency model for the calling thread, or the thread that called CoInitializeEx currently belongs to the neutral threaded apartment. <br />
so perhaps you are mistaking an "already initialized" return code for an "error" return code.
Here is a function to retrieve an error message from a HRESULT:
CString CApp::GetErrorText(HRESULT hr)
{
if(FACILITY_WINDOWS == HRESULT_FACILITY(hr))
hr = HRESULT_CODE(hr);
TCHAR* szErrMsg;
if(::FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,
NULL, hr, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR)&szErrMsg, 0, NULL) != 0)
{
LocalFree(szErrMsg);
}
else
{
_stprintf(szErrMsg, _T("Unkown Error: %#x"), hr);
}
return CString(szErrMsg);
}