// d:\projects\ppp\ppp\debug\flash10l.tlh
//
// C++ source equivalent of Win32 type library C:\WINDOWS\system32\Macromed\Flash\Flash10l.ocx
// compiler-generated file created 01/08/11 at 18:16:41 - DO NOT EDIT!#pragma once
#pragma pack(push, 8)#include <comdef.h>//
// Forward references and typedefs
//struct __declspec(uuid("d27cdb6b-ae6d-11cf-96b8-444553540000"))
/* LIBID */ __ShockwaveFlashObjects;
struct __declspec(uuid("d27cdb6c-ae6d-11cf-96b8-444553540000"))
/* dual interface */ IShockwaveFlash;
struct __declspec(uuid("c5598e60-b307-11d1-b27d-006008c3fbfb"))
/* interface */ ICanHandleException;
struct __declspec(uuid("d27cdb6d-ae6d-11cf-96b8-444553540000"))
/* dispinterface */ _IShockwaveFlashEvents;
struct /* coclass */ ShockwaveFlash;
struct __declspec(uuid("d27cdb70-ae6d-11cf-96b8-444553540000"))
/* interface */ IFlashFactory;
struct __declspec(uuid("d27cdb72-ae6d-11cf-96b8-444553540000"))
/* interface */ IFlashObjectInterface;
struct __declspec(uuid("a6ef9860-c720-11d0-9337-00a0c90dcaa9"))
/* interface */ IDispatchEx;
struct /* coclass */ FlashObjectInterface;
struct __declspec(uuid("86230738-d762-4c50-a2de-a753e5b1686f"))
/* dual interface */ IFlashObject;
struct /* coclass */ FlashObject;
。
//////我的代码/////////////
//IFlashObjectInterfacePtr pifo;
IUnknown *punk;
IShockwaveFlashPtr isf;
IFlashObjectInterfacePtr isfo;
IFlashObjectPtr isfoo;
HWND pwnd;
HRESULT hr;
IID clid;
IIDFromString(L"e0920e11-6b65-4d5d-9c58-b1fc5c07dc43",&clid);
hr=CoCreateInstance(__uuidof(ShockwaveFlash),NULL,CLSCTX_INPROC_SERVER,__uuidof(IShockwaveFlash),(void **)&isf);
this->GetDlgItem(IDC_SHOCKWAVEFLASH2,&pwnd);
AtlAxAttachControl(isf,pwnd,NULL);
hr=isf->QueryInterface(__uuidof(IUnknown),(void **)&punk);
hr=CoCreateInstance(clid,punk,CLSCTX_INPROC_SERVER,__uuidof(IFlashObject),(void **)&isfoo); 这句出错 hr返回值 为 ”没有注册“
_bstr_t aa="D:\\testflash\\test.swf";
isf->put_Movie(aa);
return ;
//
// C++ source equivalent of Win32 type library C:\WINDOWS\system32\Macromed\Flash\Flash10l.ocx
// compiler-generated file created 01/08/11 at 18:16:41 - DO NOT EDIT!#pragma once
#pragma pack(push, 8)#include <comdef.h>//
// Forward references and typedefs
//struct __declspec(uuid("d27cdb6b-ae6d-11cf-96b8-444553540000"))
/* LIBID */ __ShockwaveFlashObjects;
struct __declspec(uuid("d27cdb6c-ae6d-11cf-96b8-444553540000"))
/* dual interface */ IShockwaveFlash;
struct __declspec(uuid("c5598e60-b307-11d1-b27d-006008c3fbfb"))
/* interface */ ICanHandleException;
struct __declspec(uuid("d27cdb6d-ae6d-11cf-96b8-444553540000"))
/* dispinterface */ _IShockwaveFlashEvents;
struct /* coclass */ ShockwaveFlash;
struct __declspec(uuid("d27cdb70-ae6d-11cf-96b8-444553540000"))
/* interface */ IFlashFactory;
struct __declspec(uuid("d27cdb72-ae6d-11cf-96b8-444553540000"))
/* interface */ IFlashObjectInterface;
struct __declspec(uuid("a6ef9860-c720-11d0-9337-00a0c90dcaa9"))
/* interface */ IDispatchEx;
struct /* coclass */ FlashObjectInterface;
struct __declspec(uuid("86230738-d762-4c50-a2de-a753e5b1686f"))
/* dual interface */ IFlashObject;
struct /* coclass */ FlashObject;
。
//////我的代码/////////////
//IFlashObjectInterfacePtr pifo;
IUnknown *punk;
IShockwaveFlashPtr isf;
IFlashObjectInterfacePtr isfo;
IFlashObjectPtr isfoo;
HWND pwnd;
HRESULT hr;
IID clid;
IIDFromString(L"e0920e11-6b65-4d5d-9c58-b1fc5c07dc43",&clid);
hr=CoCreateInstance(__uuidof(ShockwaveFlash),NULL,CLSCTX_INPROC_SERVER,__uuidof(IShockwaveFlash),(void **)&isf);
this->GetDlgItem(IDC_SHOCKWAVEFLASH2,&pwnd);
AtlAxAttachControl(isf,pwnd,NULL);
hr=isf->QueryInterface(__uuidof(IUnknown),(void **)&punk);
hr=CoCreateInstance(clid,punk,CLSCTX_INPROC_SERVER,__uuidof(IFlashObject),(void **)&isfoo); 这句出错 hr返回值 为 ”没有注册“
_bstr_t aa="D:\\testflash\\test.swf";
isf->put_Movie(aa);
return ;
Flash对象为什么要实现IDispatchEx?
#import "C:\WINDOWS\system32\Macromed\Flash\Flash10l.ocx" \
raw_interfaces_only, /* Don't add raw_ to method names */ \
raw_native_types, /* Don't map to DTC smart types */ \
named_guids, /* Named guids and declspecs */ \
no_namespace /* Don't wrap with C++ name space */
就会在debug目录下生成一个 tlh 文件 您可以详细查看一下
flash 实现IDispatchEx 的意义就在于为它的 as脚本(和 javascript类似)提供一种更加底层的访问途径
virtual HRESULT STDMETHODCALLTYPE OnReadyStateChange(MovieState newState);
virtual HRESULT STDMETHODCALLTYPE OnProgress(long percentDone);
virtual HRESULT STDMETHODCALLTYPE FSCommand(BSTR command, BSTR args);
virtual HRESULT STDMETHODCALLTYPE FlashCall(BSTR request);
这几个事件的话,应该使用如下代码:
hr = AtlAdvise(pUnkControl, pFlashEvents, ShockwaveFlashObjects::DIID__IShockwaveFlashEvents, &m_dwConnectionPointID);
并在pFlashEvents的类中重写Invoke:
HRESULT STDMETHODCALLTYPE CFlashWnd::Invoke(DISPID dispIdMember, REFIID riid,
LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, LPVARIANT pVarResult,
LPEXCEPINFO pExcepInfo, LPUINT puArgErr)
{
HRESULT hr = DISP_E_BADCALLEE; if (!pDispParams)
hr = DISP_E_BADVARTYPE; if (pDispParams->cNamedArgs != 0)
hr = DISP_E_NONAMEDARGS; switch (dispIdMember)
{
case DISPID_FLASHEVENT_FLASHCALL:
hr = FlashCall(pDispParams->rgvarg[0].bstrVal);
break;
case DISPID_FLASHEVENT_FSCOMMAND:
hr = FSCommand(pDispParams->rgvarg[1].bstrVal, pDispParams->rgvarg[0].bstrVal);
break;
case DISPID_FLASHEVENT_ONPROGRESS:
hr = OnProgress(pDispParams->rgvarg[0].lVal);
break;
case DISPID_READYSTATECHANGE:
hr = OnReadyStateChange((MovieState)pDispParams->rgvarg[0].lVal);
break;
default:
//hr = COleContainerWnd<ShockwaveFlashObjects::IShockwaveFlash>::Invoke(
// dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
int a = 0;
}
return hr;
}
hr=isf->QueryInterface(__uuidof(IFlashObject),(void **)&你的指针);或者
hr=punk->QueryInterface(__uuidof(IFlashObject),(void **)&你的指针);
QueryInterface实现的功能类似于c++的cast功能
hr=isf->QueryInterface(__uuidof(IFlashObject),(void **)&你的指针);或者
hr=punk->QueryInterface(__uuidof(IFlashObject),(void **)&你的指针);
QueryInterface实现的功能类似于c++的cast功能
返回值为 nointerface!!!!!!!!!!!!!!!!!1
做成一个ocx,在html里调用,按需求把接口设计好
Flash对象为什么要实现IDispatchEx?