直接创建OLE对象,未注册的ocx也可以使用(适用于com接口)

HMODULE flashDLL = LoadLibrary(L"\\Flash10c.dll")


先加载dll,以flash插件为准

REFCLSID rclsid :class id

 REFIID riid :接口id

 LPVOID * ppv :返回查询的结果


	typedef HRESULT (__stdcall *DllGetClassObjectFunc)(REFCLSID rclsid, REFIID riid, LPVOID * ppv);

	hr = CoCreateInstance(CLSID_ShockwaveFlash, NULL, CLSCTX_INPROC_SERVER, IID_IOleObject, (void**)&m_oleObject);
	//add by xxj 2014/03/25 17: 34: 24
	if (FAILED(hr))//用户没有安装flash 则使用自己的flash
	{
		IClassFactory* aClassFactory = NULL;
		DllGetClassObjectFunc aDllGetClassObjectFunc = (DllGetClassObjectFunc) GetProcAddress(flashDLL, "DllGetClassObject");
		hr = aDllGetClassObjectFunc(CLSID_ShockwaveFlash, IID_IClassFactory, (void**)&aClassFactory);

		if (FAILED(hr))
			return;

		aClassFactory->CreateInstance(NULL, IID_IOleObject, (void**)&m_oleObject);
		aClassFactory->Release();
	}


你可能感兴趣的:(C++,ocx,Flash,com,ole)