描述:
函数原型:
STDAPI CoCreateInstance(
REFCLSID rclsid, //Class identifier (CLSID) of the object
LPUNKNOWN pUnkOuter, //Pointer to controlling IUnknown
DWORD dwClsContext, //Context for running executable code
REFIID riid, //Reference to the identifier of the interface
LPVOID * ppv //Address of output variable that receives
// the interface pointer requested in riid
);
我在做一个东西,将Win32下面的一个project转为MFC的,可是遇到了CoCreateInstance(),怎么也下不去,返回的不是S_OK。我对这个函数一点也不懂。希望有人帮帮忙。
我的相关代码:
IGraphBuilder *pGB;//DirectShow里面的一个类
CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER,
IID_IGraphBuilder, (void **)&pGB);
解决方案1:
先 CoInitialize(NULL);
用完了再 CoUninitialize();
参考:
http://www.vchelp.net/itbookreview/view_paper.asp?paper_id=1038
需要初始化COM库!呵呵
您可能想查找下面的文章:
- CoCreateInstance和CoCreateInstanceEx的区别??
- 抓狂!看了几天了,CoCreateInstance总是出错!!!!救命啊!
- 请教CoCreateInstanceEx产生E_ACCESSDENIED的原因
- CoCreateInstance的内部实现问题??
- 在DEV-CPP中编译建立快捷方式代码出现incompatibletypeforargument1of`CoCreateInstance'
- 用dll的COM除了cocreateinstance能不能就当普通DLL用loadlibrary调用。
- CoCreateInstanceEx问题
- CoCreateInstance调用成功,CoGetClassObject调用失败,为什么?
- CoCreateInstance调用出错,帮看看!
- CoCreateInstance的问题