類別 WIN32OLE::Param
公開類別方法
new(method, n) → WIN32OLE_PARAM 物件 按一下以切換來源
傳回 WIN32OLE_PARAM 物件,它代表 OLE 參數資訊。第一個引數應該是 WIN32OLE_METHOD 物件。第二個引數「n」是第一個引數所指定的 method 的第 n 個參數。
tobj = WIN32OLE_TYPE.new('Microsoft Scripting Runtime', 'IFileSystem') method = WIN32OLE_METHOD.new(tobj, 'CreateTextFile') param = WIN32OLE_PARAM.new(method, 2) # => #<WIN32OLE_PARAM:Overwrite=true>
static VALUE foleparam_initialize(VALUE self, VALUE olemethod, VALUE n) { int idx; if (!rb_obj_is_kind_of(olemethod, cWIN32OLE_METHOD)) { rb_raise(rb_eTypeError, "1st parameter must be WIN32OLE_METHOD object"); } idx = RB_FIX2INT(n); return oleparam_ole_param(self, olemethod, idx); }
公開實例方法
WIN32OLE_PARAM#default 按一下以切換來源
傳回預設值。如果沒有預設值,這個方法會傳回 nil。
tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook') method = WIN32OLE_METHOD.new(tobj, 'SaveAs') method.params.each do |param| if param.default puts "#{param.name} (= #{param.default})" else puts "#{param}" end end The above script result is following: Filename FileFormat Password WriteResPassword ReadOnlyRecommended CreateBackup AccessMode (= 1) ConflictResolution AddToMru TextCodepage TextVisualLayout
static VALUE foleparam_default(VALUE self) { struct oleparamdata *pparam; TypedData_Get_Struct(self, struct oleparamdata, &oleparam_datatype, pparam); return ole_param_default(pparam->pTypeInfo, pparam->method_index, pparam->index); }
WIN32OLE_PARAM#input? 按一下以切換來源
如果參數是輸入,傳回 true。
tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook') method = WIN32OLE_METHOD.new(tobj, 'SaveAs') param1 = method.params[0] puts param1.input? # => true
static VALUE foleparam_input(VALUE self) { struct oleparamdata *pparam; TypedData_Get_Struct(self, struct oleparamdata, &oleparam_datatype, pparam); return ole_param_flag_mask(pparam->pTypeInfo, pparam->method_index, pparam->index, PARAMFLAG_FIN); }
WIN32OLE_PARAM#inspect → 字串 按一下以切換來源
傳回參數名稱和類別名稱。如果參數有預設值,則傳回名稱=值字串和類別名稱。
static VALUE foleparam_inspect(VALUE self) { VALUE detail = foleparam_name(self); VALUE defval = foleparam_default(self); if (defval != Qnil) { rb_str_cat2(detail, "="); rb_str_concat(detail, rb_inspect(defval)); } return make_inspect("WIN32OLE_PARAM", detail); }
WIN32OLE_PARAM#name 按一下以切換來源
傳回名稱。
tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook') method = WIN32OLE_METHOD.new(tobj, 'SaveAs') param1 = method.params[0] puts param1.name # => Filename
static VALUE foleparam_name(VALUE self) { return rb_ivar_get(self, rb_intern("name")); }
別名:to_s
WIN32OLE_PARAM#ole_type 按一下以切換來源
傳回 WIN32OLE_PARAM 物件 (OLE 方法的參數) 的 OLE 類型。
tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook') method = WIN32OLE_METHOD.new(tobj, 'SaveAs') param1 = method.params[0] puts param1.ole_type # => VARIANT
static VALUE foleparam_ole_type(VALUE self) { struct oleparamdata *pparam; TypedData_Get_Struct(self, struct oleparamdata, &oleparam_datatype, pparam); return ole_param_ole_type(pparam->pTypeInfo, pparam->method_index, pparam->index); }
WIN32OLE_PARAM#ole_type_detail 按一下以切換來源
傳回引數類型的詳細資訊。
tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'IWorksheetFunction') method = WIN32OLE_METHOD.new(tobj, 'SumIf') param1 = method.params[0] p param1.ole_type_detail # => ["PTR", "USERDEFINED", "Range"]
static VALUE foleparam_ole_type_detail(VALUE self) { struct oleparamdata *pparam; TypedData_Get_Struct(self, struct oleparamdata, &oleparam_datatype, pparam); return ole_param_ole_type_detail(pparam->pTypeInfo, pparam->method_index, pparam->index); }
WIN32OLE_PARAM#optional? 按一下以切換來源
如果引數是選用的,傳回 true。
tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook') method = WIN32OLE_METHOD.new(tobj, 'SaveAs') param1 = method.params[0] puts "#{param1.name} #{param1.optional?}" # => Filename true
static VALUE foleparam_optional(VALUE self) { struct oleparamdata *pparam; TypedData_Get_Struct(self, struct oleparamdata, &oleparam_datatype, pparam); return ole_param_flag_mask(pparam->pTypeInfo, pparam->method_index, pparam->index, PARAMFLAG_FOPT); }
WIN32OLE#output? 按一下以切換來源
如果引數是輸出,傳回 true。
tobj = WIN32OLE_TYPE.new('Microsoft Internet Controls', 'DWebBrowserEvents') method = WIN32OLE_METHOD.new(tobj, 'NewWindow') method.params.each do |param| puts "#{param.name} #{param.output?}" end The result of above script is following: URL false Flags false TargetFrameName false PostData false Headers false Processed true
static VALUE foleparam_output(VALUE self) { struct oleparamdata *pparam; TypedData_Get_Struct(self, struct oleparamdata, &oleparam_datatype, pparam); return ole_param_flag_mask(pparam->pTypeInfo, pparam->method_index, pparam->index, PARAMFLAG_FOUT); }
WIN32OLE_PARAM#retval? 按一下以切換來源
如果引數是傳回值,傳回 true。
tobj = WIN32OLE_TYPE.new('DirectX 7 for Visual Basic Type Library', 'DirectPlayLobbyConnection') method = WIN32OLE_METHOD.new(tobj, 'GetPlayerShortName') param = method.params[0] puts "#{param.name} #{param.retval?}" # => name true
static VALUE foleparam_retval(VALUE self) { struct oleparamdata *pparam; TypedData_Get_Struct(self, struct oleparamdata, &oleparam_datatype, pparam); return ole_param_flag_mask(pparam->pTypeInfo, pparam->method_index, pparam->index, PARAMFLAG_FRETVAL); }
WIN32OLE_PARAM#name
傳回名稱。
tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook') method = WIN32OLE_METHOD.new(tobj, 'SaveAs') param1 = method.params[0] puts param1.name # => Filename
別名:name