static VALUE
fole_each(VALUE self)
{
LCID lcid = cWIN32OLE_lcid;
struct oledata *pole = NULL;
unsigned int argErr;
EXCEPINFO excepinfo;
DISPPARAMS dispParams;
VARIANT result;
HRESULT hr;
IEnumVARIANT *pEnum = NULL;
void *p;
RETURN_ENUMERATOR(self, 0, 0);
VariantInit(&result);
dispParams.rgvarg = NULL;
dispParams.rgdispidNamedArgs = NULL;
dispParams.cNamedArgs = 0;
dispParams.cArgs = 0;
memset(&excepinfo, 0, sizeof(excepinfo));
pole = oledata_get_struct(self);
hr = pole->pDispatch->lpVtbl->Invoke(pole->pDispatch, DISPID_NEWENUM,
&IID_NULL, lcid,
DISPATCH_METHOD | DISPATCH_PROPERTYGET,
&dispParams, &result,
&excepinfo, &argErr);
if (FAILED(hr)) {
VariantClear(&result);
ole_raise(hr, eWIN32OLERuntimeError, "failed to get IEnum Interface");
}
if (V_VT(&result) == VT_UNKNOWN) {
hr = V_UNKNOWN(&result)->lpVtbl->QueryInterface(V_UNKNOWN(&result),
&IID_IEnumVARIANT,
&p);
pEnum = p;
} else if (V_VT(&result) == VT_DISPATCH) {
hr = V_DISPATCH(&result)->lpVtbl->QueryInterface(V_DISPATCH(&result),
&IID_IEnumVARIANT,
&p);
pEnum = p;
}
if (FAILED(hr) || !pEnum) {
VariantClear(&result);
ole_raise(hr, rb_eRuntimeError, "failed to get IEnum Interface");
}
VariantClear(&result);
rb_ensure(ole_each_sub, (VALUE)pEnum, ole_ienum_free, (VALUE)pEnum);
return Qnil;
}