static HRESULT \
IDispatch_VarGet (IDispatch *pRDisp, LPOLESTR Name, VARIANT *pVarRes)
{
DISPPARAMS DispParams;
DISPID dispid;
HRESULT hr;
if ((hr = IDispatch_GetIDsOfNames (pRDisp, &IID_NULL,
&Name, 1, LOCALE_SYSTEM_DEFAULT, &dispid)))
return hr;
ZeroMemory (&DispParams, sizeof (DispParams));
hr = IDispatch_Invoke (pRDisp, dispid, &IID_NULL,
LOCALE_SYSTEM_DEFAULT, DISPATCH_PROPERTYGET,
&DispParams, pVarRes, NULL, NULL);
return hr;
}
static HRESULT \
IDispatch_VarPut (IDispatch *pRDisp, LPOLESTR Name, VARIANT *pVarArg)
{
DISPPARAMS DispParams;
DISPID dispid, ndispid;
HRESULT hr;
if ((hr = IDispatch_GetIDsOfNames (pRDisp, &IID_NULL,
&Name, 1, LOCALE_SYSTEM_DEFAULT, &dispid)))
return hr;
ndispid = DISPID_PROPERTYPUT;
DispParams.rgvarg = pVarArg;
DispParams.rgdispidNamedArgs = &ndispid;
DispParams.cArgs = 1;
DispParams.cNamedArgs = 1;
hr = IDispatch_Invoke (pRDisp, dispid, &IID_NULL,
LOCALE_SYSTEM_DEFAULT, DISPATCH_PROPERTYPUT,
&DispParams, NULL, NULL, NULL);
return hr;
}
static HRESULT \
IDispatch_StrPut (IDispatch *pRDisp, LPOLESTR Name, LPOLESTR StrVal)
{
VARIANT varg;
HRESULT hr;
VariantInit (&varg);
V_VT (&varg) = VT_BSTR;
V_BSTR (&varg) = SysAllocString (StrVal);
hr = IDispatch_VarPut (pRDisp, Name, &varg);
VariantClear (&varg);
return hr;
}
static HRESULT \
IDispatch_IntPut (IDispatch *pRDisp, LPOLESTR Name, int IntVal)
{
VARIANT varg;
HRESULT hr;
VariantInit (&varg);
V_VT (&varg) = VT_I4;
V_I4 (&varg) = IntVal;
hr = IDispatch_VarPut (pRDisp, Name, &varg);
VariantClear (&varg);
return hr;
}
...
if ((hr = IDispatch_StrPut (pRDisp, L"code", buff)))
return hr;
if ((hr = IDispatch_IntPut (pRDisp, L"state", state)))
return hr;
...
{
// ...
VariantInit (&varg);
if ((hr = IDispatch_VarGet (pRDisp, L"code", &varg)))
{
VariantClear (&varg);
return hr;
}
if (V_VT (&varg) == VT_BSTR)
// ...
VariantClear (&varg);
return hr;
}
和 java 代码示例...
var frec = {code:'', state:0};
frec.code = row.cells[0].innerHTML;
external.FeatureStateChg (frec);
_featState (row.cells[2], frec.state);
...
var frec = {code:'', name:'', state:0};
if (!external.FeaturesEnum (frec, i))
break;