Class: WIN32OLE_TYPE
- Inherits:
-
Object
- Object
- WIN32OLE_TYPE
- Defined in:
- win32ole.c,
win32ole.c
Overview
WIN32OLE_TYPE
objects represent OLE type libarary information.
Class Method Summary collapse
-
.ole_classes(typelib) ⇒ Object
Returns array of WIN32OLE_TYPE objects defined by the typelib type library.
-
.progids ⇒ Object
Returns array of ProgID.
-
.typelibs ⇒ Object
Returns array of type libraries.
Instance Method Summary collapse
-
#default_event_sources ⇒ Object
Returns the array of WIN32OLE_TYPE object which is implemented by the WIN32OLE_TYPE object and having IMPLTYPEFLAG_FSOURCE and IMPLTYPEFLAG_FDEFAULT.
-
#default_ole_types ⇒ Object
Returns the array of WIN32OLE_TYPE object which is implemented by the WIN32OLE_TYPE object and having IMPLTYPEFLAG_FDEFAULT.
-
#guid ⇒ Object
Returns GUID.
-
#helpcontext ⇒ Object
Returns helpcontext.
-
#helpfile ⇒ Object
Returns helpfile path.
-
#helpstring ⇒ Object
Returns help string.
-
#implemented_ole_types ⇒ Object
Returns the array of WIN32OLE_TYPE object which is implemented by the WIN32OLE_TYPE object.
-
#new(typelib, ole_class) ⇒ WIN32OLE_TYPE object
constructor
Returns a new WIN32OLE_TYPE object.
-
#inspect ⇒ String
Returns the type name with class name.
-
#major_version ⇒ Object
Returns major version.
-
#minor_version ⇒ Object
Returns minor version.
-
#name ⇒ Object
(also: #to_s)
Returns OLE type name.
-
#ole_methods ⇒ Object
Returns array of WIN32OLE_METHOD objects which represent OLE method defined in OLE type library.
-
#ole_type ⇒ Object
returns type of OLE class.
-
#ole_typelib ⇒ Object
Returns the WIN32OLE_TYPELIB object which is including the WIN32OLE_TYPE object.
-
#progid ⇒ Object
Returns ProgID if it exists.
-
#source_ole_types ⇒ Object
Returns the array of WIN32OLE_TYPE object which is implemented by the WIN32OLE_TYPE object and having IMPLTYPEFLAG_FSOURCE.
-
#src_type ⇒ Object
Returns source class when the OLE class is ‘Alias’.
-
#typekind ⇒ Object
Returns number which represents type.
-
#variables ⇒ Object
Returns array of WIN32OLE_VARIABLE objects which represent variables defined in OLE class.
-
#visible? ⇒ Boolean
Returns true if the OLE class is public.
Constructor Details
#new(typelib, ole_class) ⇒ WIN32OLE_TYPE object
Returns a new WIN32OLE_TYPE object. The first argument typelib specifies OLE type library name. The second argument specifies OLE class name.
WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Application')
# => WIN32OLE_TYPE object of Application class of Excel.
5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 |
# File 'win32ole.c', line 5558
static VALUE
foletype_initialize(VALUE self, VALUE typelib, VALUE oleclass)
{
VALUE file;
OLECHAR * pbuf;
ITypeLib *pTypeLib;
HRESULT hr;
SafeStringValue(oleclass);
SafeStringValue(typelib);
file = typelib_file(typelib);
if (file == Qnil) {
file = typelib;
}
pbuf = ole_vstr2wc(file);
hr = LoadTypeLibEx(pbuf, REGKIND_NONE, &pTypeLib);
if (FAILED(hr))
ole_raise(hr, eWIN32OLERuntimeError, "failed to LoadTypeLibEx");
SysFreeString(pbuf);
if (oleclass_from_typelib(self, pTypeLib, oleclass) == Qfalse) {
OLE_RELEASE(pTypeLib);
rb_raise(eWIN32OLERuntimeError, "not found `%s` in `%s`",
StringValuePtr(oleclass), StringValuePtr(typelib));
}
OLE_RELEASE(pTypeLib);
return self;
}
|
Class Method Details
.ole_classes(typelib) ⇒ Object
Returns array of WIN32OLE_TYPE objects defined by the typelib type library. This method will be OBSOLETE. Use WIN32OLE_TYPELIB.new(typelib).ole_classes instead.
4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 |
# File 'win32ole.c', line 4807
static VALUE
foletype_s_ole_classes(VALUE self, VALUE typelib)
{
VALUE obj;
/*
rb_warn("%s is obsolete; use %s instead.",
"WIN32OLE_TYPE.ole_classes",
"WIN32OLE_TYPELIB.new(typelib).ole_types");
*/
obj = rb_funcall(cWIN32OLE_TYPELIB, rb_intern("new"), 1, typelib);
return rb_funcall(obj, rb_intern("ole_types"), 0);
}
|
.progids ⇒ Object
Returns array of ProgID.
4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 |
# File 'win32ole.c', line 4846
static VALUE
foletype_s_progids(VALUE self)
{
HKEY hclsids, hclsid;
DWORD i;
LONG err;
VALUE clsid;
VALUE v = rb_str_new2("");
VALUE progids = rb_ary_new();
err = reg_open_key(HKEY_CLASSES_ROOT, "CLSID", &hclsids);
if(err != ERROR_SUCCESS) {
return progids;
}
for(i = 0; ; i++) {
clsid = reg_enum_key(hclsids, i);
if (clsid == Qnil)
break;
err = reg_open_vkey(hclsids, clsid, &hclsid);
if (err != ERROR_SUCCESS)
continue;
if ((v = reg_get_val2(hclsid, "ProgID")) != Qnil)
rb_ary_push(progids, v);
if ((v = reg_get_val2(hclsid, "VersionIndependentProgID")) != Qnil)
rb_ary_push(progids, v);
RegCloseKey(hclsid);
}
RegCloseKey(hclsids);
return progids;
}
|
.typelibs ⇒ Object
Returns array of type libraries. This method will be OBSOLETE. Use WIN32OLE_TYPELIB.typelibs.collect{|t| t.name} instead.
4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 |
# File 'win32ole.c', line 4829
static VALUE
foletype_s_typelibs(VALUE self)
{
/*
rb_warn("%s is obsolete. use %s instead.",
"WIN32OLE_TYPE.typelibs",
"WIN32OLE_TYPELIB.typelibs.collect{t|t.name}");
*/
return rb_eval_string("WIN32OLE_TYPELIB.typelibs.collect{|t|t.name}");
}
|
Instance Method Details
#default_event_sources ⇒ Object
Returns the array of WIN32OLE_TYPE object which is implemented by the WIN32OLE_TYPE object and having IMPLTYPEFLAG_FSOURCE and IMPLTYPEFLAG_FDEFAULT.
tobj = WIN32OLE_TYPE.new('Microsoft Internet Controls', "InternetExplorer")
p tobj.default_event_sources # => [#<WIN32OLE_TYPE:DWebBrowserEvents2>]
6080 6081 6082 6083 6084 6085 6086 |
# File 'win32ole.c', line 6080
static VALUE
foletype_default_event_sources(VALUE self)
{
struct oletypedata *ptype;
Data_Get_Struct(self, struct oletypedata, ptype);
return ole_type_impl_ole_types(ptype->pTypeInfo, IMPLTYPEFLAG_FSOURCE|IMPLTYPEFLAG_FDEFAULT);
}
|
#default_ole_types ⇒ Object
Returns the array of WIN32OLE_TYPE object which is implemented by the WIN32OLE_TYPE object and having IMPLTYPEFLAG_FDEFAULT.
tobj = WIN32OLE_TYPE.new('Microsoft Internet Controls', "InternetExplorer")
p tobj.default_ole_types
# => [#<WIN32OLE_TYPE:IWebBrowser2>, #<WIN32OLE_TYPE:DWebBrowserEvents2>]
6098 6099 6100 6101 6102 6103 6104 |
# File 'win32ole.c', line 6098
static VALUE
foletype_default_ole_types(VALUE self)
{
struct oletypedata *ptype;
Data_Get_Struct(self, struct oletypedata, ptype);
return ole_type_impl_ole_types(ptype->pTypeInfo, IMPLTYPEFLAG_FDEFAULT);
}
|
#guid ⇒ Object
Returns GUID.
tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Application')
puts tobj.guid # => {00024500-0000-0000-C000-000000000046}
5689 5690 5691 5692 5693 5694 5695 |
# File 'win32ole.c', line 5689
static VALUE
foletype_guid(VALUE self)
{
struct oletypedata *ptype;
Data_Get_Struct(self, struct oletypedata, ptype);
return ole_type_guid(ptype->pTypeInfo);
}
|
#helpcontext ⇒ Object
Returns helpcontext. If helpcontext is not found, then returns nil.
tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Worksheet')
puts tobj.helpfile # => 131185
5970 5971 5972 5973 5974 5975 5976 |
# File 'win32ole.c', line 5970
static VALUE
foletype_helpcontext(VALUE self)
{
struct oletypedata *ptype;
Data_Get_Struct(self, struct oletypedata, ptype);
return ole_type_helpcontext(ptype->pTypeInfo);
}
|
#helpfile ⇒ Object
Returns helpfile path. If helpfile is not found, then returns nil.
tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Worksheet')
puts tobj.helpfile # => C:\...\VBAXL9.CHM
5942 5943 5944 5945 5946 5947 5948 |
# File 'win32ole.c', line 5942
static VALUE
foletype_helpfile(VALUE self)
{
struct oletypedata *ptype;
Data_Get_Struct(self, struct oletypedata, ptype);
return ole_type_helpfile(ptype->pTypeInfo);
}
|
#helpstring ⇒ Object
Returns help string.
tobj = WIN32OLE_TYPE.new('Microsoft Internet Controls', 'IWebBrowser')
puts tobj.helpstring # => Web Browser interface
5878 5879 5880 5881 5882 5883 5884 |
# File 'win32ole.c', line 5878
static VALUE
foletype_helpstring(VALUE self)
{
struct oletypedata *ptype;
Data_Get_Struct(self, struct oletypedata, ptype);
return ole_type_helpstring(ptype->pTypeInfo);
}
|
#implemented_ole_types ⇒ Object
Returns the array of WIN32OLE_TYPE object which is implemented by the WIN32OLE_TYPE object.
tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Worksheet')
p tobj.implemented_ole_types # => [_Worksheet, DocEvents]
6045 6046 6047 6048 6049 6050 6051 |
# File 'win32ole.c', line 6045
static VALUE
foletype_impl_ole_types(VALUE self)
{
struct oletypedata *ptype;
Data_Get_Struct(self, struct oletypedata, ptype);
return ole_type_impl_ole_types(ptype->pTypeInfo, 0);
}
|
#inspect ⇒ String
Returns the type name with class name.
ie = WIN32OLE.new('InternetExplorer.Application')
ie.ole_type.inspect => #<WIN32OLE_TYPE:IWebBrowser2>
6115 6116 6117 6118 6119 |
# File 'win32ole.c', line 6115
static VALUE
foletype_inspect(VALUE self)
{
return default_inspect(self, "WIN32OLE_TYPE");
}
|
#major_version ⇒ Object
Returns major version.
tobj = WIN32OLE_TYPE.new('Microsoft Word 10.0 Object Library', 'Documents')
puts tobj.major_version # => 8
5789 5790 5791 5792 5793 5794 5795 |
# File 'win32ole.c', line 5789
static VALUE
foletype_major_version(VALUE self)
{
struct oletypedata *ptype;
Data_Get_Struct(self, struct oletypedata, ptype);
return ole_type_major_version(ptype->pTypeInfo);
}
|
#minor_version ⇒ Object
Returns minor version.
tobj = WIN32OLE_TYPE.new('Microsoft Word 10.0 Object Library', 'Documents')
puts tobj.minor_version # => 2
5819 5820 5821 5822 5823 5824 5825 |
# File 'win32ole.c', line 5819
static VALUE
foletype_minor_version(VALUE self)
{
struct oletypedata *ptype;
Data_Get_Struct(self, struct oletypedata, ptype);
return ole_type_minor_version(ptype->pTypeInfo);
}
|
#name ⇒ Object Also known as: to_s
Returns OLE type name.
tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Application')
puts tobj.name # => Application
5594 5595 5596 5597 5598 |
# File 'win32ole.c', line 5594
static VALUE
foletype_name(VALUE self)
{
return rb_ivar_get(self, rb_intern("name"));
}
|
#ole_methods ⇒ Object
Returns array of WIN32OLE_METHOD objects which represent OLE method defined in OLE type library.
tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Worksheet')
methods = tobj.ole_methods.collect{|m|
m.name
}
# => ['Activate', 'Copy', 'Delete',....]
6203 6204 6205 6206 6207 6208 6209 |
# File 'win32ole.c', line 6203
static VALUE
foletype_methods(VALUE self)
{
struct oletypedata *ptype;
Data_Get_Struct(self, struct oletypedata, ptype);
return ole_methods_from_typeinfo(ptype->pTypeInfo, INVOKE_FUNC | INVOKE_PROPERTYGET | INVOKE_PROPERTYPUT | INVOKE_PROPERTYPUTREF);
}
|
#ole_type ⇒ Object
returns type of OLE class.
tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Application')
puts tobj.ole_type # => Class
5654 5655 5656 5657 5658 5659 5660 |
# File 'win32ole.c', line 5654
static VALUE
foletype_ole_type(VALUE self)
{
struct oletypedata *ptype;
Data_Get_Struct(self, struct oletypedata, ptype);
return ole_ole_type(ptype->pTypeInfo);
}
|
#ole_typelib ⇒ Object
Returns the WIN32OLE_TYPELIB object which is including the WIN32OLE_TYPE object. If it is not found, then returns nil.
tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Worksheet')
puts tobj.ole_typelib # => 'Microsoft Excel 9.0 Object Library'
5987 5988 5989 5990 5991 5992 5993 |
# File 'win32ole.c', line 5987
static VALUE
foletype_ole_typelib(VALUE self)
{
struct oletypedata *ptype;
Data_Get_Struct(self, struct oletypedata, ptype);
return ole_typelib_from_itypeinfo(ptype->pTypeInfo);
}
|
#progid ⇒ Object
Returns ProgID if it exists. If not found, then returns nil.
tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Application')
puts tobj.progid # => Excel.Application.9
5724 5725 5726 5727 5728 5729 5730 |
# File 'win32ole.c', line 5724
static VALUE
foletype_progid(VALUE self)
{
struct oletypedata *ptype;
Data_Get_Struct(self, struct oletypedata, ptype);
return ole_type_progid(ptype->pTypeInfo);
}
|
#source_ole_types ⇒ Object
Returns the array of WIN32OLE_TYPE object which is implemented by the WIN32OLE_TYPE object and having IMPLTYPEFLAG_FSOURCE.
tobj = WIN32OLE_TYPE.new('Microsoft Internet Controls', "InternetExplorer")
p tobj.source_ole_types
# => [#<WIN32OLE_TYPE:DWebBrowserEvents2>, #<WIN32OLE_TYPE:DWebBrowserEvents>]
6063 6064 6065 6066 6067 6068 6069 |
# File 'win32ole.c', line 6063
static VALUE
foletype_source_ole_types(VALUE self)
{
struct oletypedata *ptype;
Data_Get_Struct(self, struct oletypedata, ptype);
return ole_type_impl_ole_types(ptype->pTypeInfo, IMPLTYPEFLAG_FSOURCE);
}
|
#src_type ⇒ Object
Returns source class when the OLE class is ‘Alias’.
tobj = WIN32OLE_TYPE.new('Microsoft Office 9.0 Object Library', 'MsoRGBType')
puts tobj.src_type # => I4
5913 5914 5915 5916 5917 5918 5919 |
# File 'win32ole.c', line 5913
static VALUE
foletype_src_type(VALUE self)
{
struct oletypedata *ptype;
Data_Get_Struct(self, struct oletypedata, ptype);
return ole_type_src_type(ptype->pTypeInfo);
}
|
#typekind ⇒ Object
Returns number which represents type.
tobj = WIN32OLE_TYPE.new('Microsoft Word 10.0 Object Library', 'Documents')
puts tobj.typekind # => 4
5850 5851 5852 5853 5854 5855 5856 |
# File 'win32ole.c', line 5850
static VALUE
foletype_typekind(VALUE self)
{
struct oletypedata *ptype;
Data_Get_Struct(self, struct oletypedata, ptype);
return ole_type_typekind(ptype->pTypeInfo);
}
|
#variables ⇒ Object
Returns array of WIN32OLE_VARIABLE objects which represent variables defined in OLE class.
tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'XlSheetType')
vars = tobj.variables
vars.each do |v|
puts "#{v.name} = #{v.value}"
end
The result of above sample script is follows:
xlChart = -4109
xlDialogSheet = -4116
xlExcel4IntlMacroSheet = 4
xlExcel4MacroSheet = 3
xlWorksheet = -4167
6183 6184 6185 6186 6187 6188 6189 |
# File 'win32ole.c', line 6183
static VALUE
foletype_variables(VALUE self)
{
struct oletypedata *ptype;
Data_Get_Struct(self, struct oletypedata, ptype);
return ole_variables(ptype->pTypeInfo);
}
|
#visible? ⇒ Boolean
Returns true if the OLE class is public.
tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Application')
puts tobj.visible # => true
5759 5760 5761 5762 5763 5764 5765 |
# File 'win32ole.c', line 5759
static VALUE
foletype_visible(VALUE self)
{
struct oletypedata *ptype;
Data_Get_Struct(self, struct oletypedata, ptype);
return ole_type_visible(ptype->pTypeInfo);
}
|