描述:
我只不过在对话框上加了个datagrid的activex控件,其他什么也没做,而我用hr=CoInitialize(NULL)时总是返回S_FALSE,搞得我非常郁闷!
那位兄弟姐妹知道,给我一点帮助
解决方案1:
你的COM组件估计已经被那个ActiveX控件调用,不需要你再调用了。
还有这个错误,是无法用GetLastError()监测到的,只是由返回值确定。
以下是MSDN的解释:
Return Values
This function supports the standard return values E_INVALIDARG, E_OUTOFMEMORY, and E_UNEXPECTED, as well as the following:
S_OK
The COM library was initialized successfully on this thread.
/****************
S_FALSE
The COM library is already initialized on this thread.
****************/
RPC_E_CHANGED_MODE
A previous call to CoInitializeEx specified the concurrency model for this thread as multithread apartment (MTA). If running Windows 2000, this could also mean that a change from neutral-threaded apartment to single-threaded apartment occurred.
初始化ole try
解决方案3:同意楼上,用GetLastError得到错误码,然后用VC的ErrorLookup看一下是什么意思就好解决了
解决方案4:如果你确信还没有初始化过com,那你就用GetLastError看看是什么错误