类 WIN32OLE::Method
公共类方法
new(ole_type, method) → WIN32OLE_METHOD 对象 点击切换源代码
返回一个新的 WIN32OLE_METHOD 对象,它代表有关 OLE 方法的信息。第一个参数 ole_type 指定 WIN32OLE_TYPE 对象。第二个参数 method 指定 OLE 类中定义的 OLE 方法名称,该 OLE 类代表 WIN32OLE_TYPE 对象。
tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook') method = WIN32OLE_METHOD.new(tobj, 'SaveAs')
static VALUE folemethod_initialize(VALUE self, VALUE oletype, VALUE method) { VALUE obj = Qnil; ITypeInfo *pTypeInfo; if (rb_obj_is_kind_of(oletype, cWIN32OLE_TYPE)) { SafeStringValue(method); pTypeInfo = itypeinfo(oletype); obj = olemethod_from_typeinfo(self, pTypeInfo, method); if (obj == Qnil) { rb_raise(eWIN32OLERuntimeError, "not found %s", StringValuePtr(method)); } } else { rb_raise(rb_eTypeError, "1st argument should be WIN32OLE_TYPE object"); } return obj; }
公共实例方法
WIN32OLE_METHOD#dispid 点击切换源代码
返回调度 ID。
tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks') method = WIN32OLE_METHOD.new(tobj, 'Add') puts method.dispid # => 181
static VALUE folemethod_dispid(VALUE self) { struct olemethoddata *pmethod; TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod); return ole_method_dispid(pmethod->pTypeInfo, pmethod->index); }
WIN32OLE_METHOD#event? 点击切换源代码
如果该方法是事件,则返回 true。
tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook') method = WIN32OLE_METHOD.new(tobj, 'SheetActivate') puts method.event? # => true
static VALUE folemethod_event(VALUE self) { struct olemethoddata *pmethod; TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod); if (!pmethod->pOwnerTypeInfo) return Qfalse; return ole_method_event(pmethod->pOwnerTypeInfo, pmethod->index, rb_ivar_get(self, rb_intern("name"))); }
WIN32OLE_METHOD#event_interface 点击切换源代码
如果该方法是事件,则返回事件接口名称。
tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook') method = WIN32OLE_METHOD.new(tobj, 'SheetActivate') puts method.event_interface # => WorkbookEvents
static VALUE folemethod_event_interface(VALUE self) { BSTR name; struct olemethoddata *pmethod; HRESULT hr; TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod); if(folemethod_event(self) == Qtrue) { hr = ole_docinfo_from_type(pmethod->pTypeInfo, &name, NULL, NULL, NULL); if(SUCCEEDED(hr)) return WC2VSTR(name); } return Qnil; }
WIN32OLE_METHOD#helpcontext 点击切换源代码
返回帮助上下文。
tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks') method = WIN32OLE_METHOD.new(tobj, 'Add') puts method.helpcontext # => 65717
static VALUE folemethod_helpcontext(VALUE self) { struct olemethoddata *pmethod; TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod); return ole_method_helpcontext(pmethod->pTypeInfo, pmethod->index); }
WIN32OLE_METHOD#helpfile 点击切换源代码
返回帮助文件。如果找不到帮助文件,则该方法返回 nil。
tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks') method = WIN32OLE_METHOD.new(tobj, 'Add') puts method.helpfile # => C:\...\VBAXL9.CHM
static VALUE folemethod_helpfile(VALUE self) { struct olemethoddata *pmethod; TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod); return ole_method_helpfile(pmethod->pTypeInfo, pmethod->index); }
WIN32OLE_METHOD#helpstring 点击切换源代码
返回 OLE 方法的帮助字符串。如果找不到帮助字符串,则该方法返回 nil。
tobj = WIN32OLE_TYPE.new('Microsoft Internet Controls', 'IWebBrowser') method = WIN32OLE_METHOD.new(tobj, 'Navigate') puts method.helpstring # => Navigates to a URL or file.
static VALUE folemethod_helpstring(VALUE self) { struct olemethoddata *pmethod; TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod); return ole_method_helpstring(pmethod->pTypeInfo, pmethod->index); }
WIN32OLE_METHOD#inspect → String 点击切换源代码
返回带有类名的该方法名称。
static VALUE folemethod_inspect(VALUE self) { return default_inspect(self, "WIN32OLE_METHOD"); }
WIN32OLE_METHOD#invkind 点击切换源代码
返回方法调用类型。
tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks') method = WIN32OLE_METHOD.new(tobj, 'Add') puts method.invkind # => 1
static VALUE folemethod_invkind(VALUE self) { struct olemethoddata *pmethod; TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod); return ole_method_invkind(pmethod->pTypeInfo, pmethod->index); }
WIN32OLE_METHOD#invoke_kind 点击切换源代码
返回方法类型字符串。字符串为“UNKNOWN”或“PROPERTY”或“PROPERTY”或“PROPERTYGET”或“PROPERTYPUT”或“PROPERTYPPUTREF”或“FUNC”。
tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks') method = WIN32OLE_METHOD.new(tobj, 'Add') puts method.invoke_kind # => "FUNC"
static VALUE folemethod_invoke_kind(VALUE self) { struct olemethoddata *pmethod; TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod); return ole_method_invoke_kind(pmethod->pTypeInfo, pmethod->index); }
WIN32OLE_METHOD#name 点击切换源代码
返回方法的名称。
tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook') method = WIN32OLE_METHOD.new(tobj, 'SaveAs') puts method.name # => SaveAs
static VALUE folemethod_name(VALUE self) { return rb_ivar_get(self, rb_intern("name")); }
别名:to_s
WIN32OLE_METHOD#offset_vtbl 点击切换源代码
返回 VTBL 的偏移量。
tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks') method = WIN32OLE_METHOD.new(tobj, 'Add') puts method.offset_vtbl # => 40
static VALUE folemethod_offset_vtbl(VALUE self) { struct olemethoddata *pmethod; TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod); return ole_method_offset_vtbl(pmethod->pTypeInfo, pmethod->index); }
WIN32OLE_METHOD#params 点击切换源代码
返回与方法参数相对应的 WIN32OLE_PARAM 对象数组。
tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook') method = WIN32OLE_METHOD.new(tobj, 'SaveAs') p method.params # => [Filename, FileFormat, Password, WriteResPassword, ReadOnlyRecommended, CreateBackup, AccessMode, ConflictResolution, AddToMru, TextCodepage, TextVisualLayout]
static VALUE folemethod_params(VALUE self) { struct olemethoddata *pmethod; TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod); return ole_method_params(pmethod->pTypeInfo, pmethod->index); }
WIN32OLE_METHOD#return_type 点击切换源代码
返回方法返回值类型的字符串。
tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks') method = WIN32OLE_METHOD.new(tobj, 'Add') puts method.return_type # => Workbook
static VALUE folemethod_return_type(VALUE self) { struct olemethoddata *pmethod; TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod); return ole_method_return_type(pmethod->pTypeInfo, pmethod->index); }
WIN32OLE_METHOD#return_type_detail 点击切换源代码
返回方法返回值类型的详细信息。信息为数组。
tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks') method = WIN32OLE_METHOD.new(tobj, 'Add') p method.return_type_detail # => ["PTR", "USERDEFINED", "Workbook"]
static VALUE folemethod_return_type_detail(VALUE self) { struct olemethoddata *pmethod; TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod); return ole_method_return_type_detail(pmethod->pTypeInfo, pmethod->index); }
WIN32OLE_METHOD#return_vtype 点击切换源代码
返回方法返回值类型的数量。
tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks') method = WIN32OLE_METHOD.new(tobj, 'Add') puts method.return_vtype # => 26
static VALUE folemethod_return_vtype(VALUE self) { struct olemethoddata *pmethod; TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod); return ole_method_return_vtype(pmethod->pTypeInfo, pmethod->index); }
WIN32OLE_METHOD#size_opt_params 点击切换源代码
返回可选参数的大小。
tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook') method = WIN32OLE_METHOD.new(tobj, 'SaveAs') puts method.size_opt_params # => 4
static VALUE folemethod_size_opt_params(VALUE self) { struct olemethoddata *pmethod; TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod); return ole_method_size_opt_params(pmethod->pTypeInfo, pmethod->index); }
WIN32OLE_METHOD#size_params 点击切换源代码
返回方法参数的大小。
tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook') method = WIN32OLE_METHOD.new(tobj, 'SaveAs') puts method.size_params # => 11
static VALUE folemethod_size_params(VALUE self) { struct olemethoddata *pmethod; TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod); return ole_method_size_params(pmethod->pTypeInfo, pmethod->index); }
WIN32OLE_METHOD#name
返回方法的名称。
tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook') method = WIN32OLE_METHOD.new(tobj, 'SaveAs') puts method.name # => SaveAs
别名:name
WIN32OLE_METHOD#visible? 点击切换源代码
如果方法是公开的,则返回 true。
tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks') method = WIN32OLE_METHOD.new(tobj, 'Add') puts method.visible? # => true
static VALUE folemethod_visible(VALUE self) { struct olemethoddata *pmethod; TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod); return ole_method_visible(pmethod->pTypeInfo, pmethod->index); }