主题:[讨论]我快急死了,高手请进来看看(回复给分)[我已经自己解决,不再给分,谢谢大家关注]
下面的代码目的是为了控制,替换网页中的Flash内容,能成功取得取得Movie属性的值,但设置新值时不能成功,返回值是 DISP_E_MEMBERNOTFOUND,请高手指教。
IDispatch *pDispatchNow;
pFlashObjNow->get_object(&pDispatchNow);//得到Flash对象的IDispatch接口
DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
VARIANT var;
BSTR bstrName( L"movie" );
DISPID dispid;
OLECHAR *pbName = bName;
unsigned int ErrValue;
VARIANTARG PutVal;
PutVal.vt = VT_BSTR;
PutVal.bstrVal = _T("Image/head.swf");
DISPPARAMS PutArgs;
PutArgs.cArgs = 1;
PutArgs.rgdispidNamedArgs = NULL;
PutArgs.rgvarg = &PutVal;
PutArgs.cNamedArgs =0;
if(S_OK==pDispatchNow->GetIDsOfNames(IID_NULL, &pbName, 1, LOCALE_USER_DEFAULT, &dispid))
{
//获取原Flash的URL
if(S_OK == pDispatchNow->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYGET, &dispparamsNoArgs, &var, NULL, &ErrValue ))
{
T1 = _T("原SWF:");
T1 += var.bstrVal;
AfxMessageBox(T1);
}
//设置新
HRESULT hrSet;
hrSet = pDispatchNow->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYPUT, &PutArgs, NULL, NULL, &ErrValue );
if(S_OK == hrSet)
{
T1 = _T("新SWF:");
T1 += var.bstrVal;
AfxMessageBox(T1);
}
else
{
T1.Format(_T("%d"),hrSet);
AfxMessageBox( T1 );
}
};
IDispatch *pDispatchNow;
pFlashObjNow->get_object(&pDispatchNow);//得到Flash对象的IDispatch接口
DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
VARIANT var;
BSTR bstrName( L"movie" );
DISPID dispid;
OLECHAR *pbName = bName;
unsigned int ErrValue;
VARIANTARG PutVal;
PutVal.vt = VT_BSTR;
PutVal.bstrVal = _T("Image/head.swf");
DISPPARAMS PutArgs;
PutArgs.cArgs = 1;
PutArgs.rgdispidNamedArgs = NULL;
PutArgs.rgvarg = &PutVal;
PutArgs.cNamedArgs =0;
if(S_OK==pDispatchNow->GetIDsOfNames(IID_NULL, &pbName, 1, LOCALE_USER_DEFAULT, &dispid))
{
//获取原Flash的URL
if(S_OK == pDispatchNow->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYGET, &dispparamsNoArgs, &var, NULL, &ErrValue ))
{
T1 = _T("原SWF:");
T1 += var.bstrVal;
AfxMessageBox(T1);
}
//设置新
HRESULT hrSet;
hrSet = pDispatchNow->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYPUT, &PutArgs, NULL, NULL, &ErrValue );
if(S_OK == hrSet)
{
T1 = _T("新SWF:");
T1 += var.bstrVal;
AfxMessageBox(T1);
}
else
{
T1.Format(_T("%d"),hrSet);
AfxMessageBox( T1 );
}
};