Class: WIN32OLE_TYPE

Inherits:
Object
  • Object
show all
Defined in:
lib/win32ole-pr.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(typelib = nil, ole_class = nil) ⇒ WIN32OLE_TYPE

Returns a new instance of WIN32OLE_TYPE.



2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
# File 'lib/win32ole-pr.rb', line 2858

def initialize(typelib=nil, ole_class=nil)
   WIN32OLE.ole_initialize()
   @pTypeInfo = nil
   
   return self if typelib.nil?
   
   unless typelib.is_a?(String)
      raise TypeError, "wrong argument type (expected String)"
   end
   unless ole_class.is_a?(String)
      raise TypeError, "wrong argument type (expected String)"
   end
   file = WIN32OLE_TYPELIB.typelib_file(typelib)
   type = typlelib if file.nil?
   buf = multi_to_wide(file)
   p = 0.chr * 4
   hr = LoadTypeLibEx(buf, REGKIND_NONE, p)
   pTypeLib = p.unpack('L').first
   if hr != S_OK
      raise WIN32OLERuntimeError, "failed to LoadTypeLibEx"
   end
   if WIN32OLE.oleclass_from_typelib(self, pTypeLib, ole_class) == false
      WIN32OLE.ole_release(pTypeLib)
      raise WIN32OLERuntimeError, "not found `#{ole_class}` in `#{typelib}`"
   end
   WIN32OLE.ole_release(pTypeLib)
   self
end

Instance Attribute Details

#pTypeInfoObject

Returns the value of attribute pTypeInfo.



2809
2810
2811
# File 'lib/win32ole-pr.rb', line 2809

def pTypeInfo
  @pTypeInfo
end

Class Method Details

.ole_classes(typelib) ⇒ Object



2817
2818
2819
# File 'lib/win32ole-pr.rb', line 2817

def self.ole_classes(typelib)
   WIN32OLE_TYPELIB.new(typelib).ole_types
end

.ole_docinfo_from_type(pTypeInfo, name, helpstr, helpcontext, helpfile) ⇒ Object



3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
# File 'lib/win32ole-pr.rb', line 3099

def self.ole_docinfo_from_type(pTypeInfo,name,helpstr,helpcontext,helpfile)
   lpVtbl = 0.chr * 4
   table = 0.chr * 80
   memcpy(lpVtbl,pTypeInfo,4)
   memcpy(table,lpVtbl.unpack('L').first,80)
   table = table.unpack('L*')
   getContainingTypeLib = Win32::API::Function.new(table[18],'PPP','L')
   p = 0.chr * 4
   i = 0.chr * 4
   hr = getContainingTypeLib.call(pTypeInfo,p,i)
   return hr if hr != S_OK
   i = i.unpack('L').first
   pTypeLib = p.unpack('L').first
   lpVtbl = 0.chr * 4
   table = 0.chr * 40
   memcpy(lpVtbl,pTypeLib,4)
   memcpy(table,lpVtbl.unpack('L').first,40)
   table = table.unpack('L*')
   getDocumentation = Win32::API::Function.new(table[9],'PLPPPP','L')
   hr = getDocumentation.call(pTypeLib, i, name, helpstr, helpcontext, helpfile)
   WIN32OLE.ole_release(pTypeLib)
   hr    
end

.ole_ptrtype2val(pTypeInfo, pTypeDesc, typedetails) ⇒ Object



3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
# File 'lib/win32ole-pr.rb', line 3163

def self.ole_ptrtype2val(pTypeInfo,pTypeDesc,typedetails)
   type = ""
   vt = pTypeDesc[4,2].unpack('S').first
   if vt == VT_PTR || vt == VT_SAFEARRAY
      typedesc = 0.chr * 8
      memcpy(typedesc,pTypeDesc[0,4].unpack('L').first,8)         
      type = ole_typedesc2val(pTypeInfo, typedesc, typedetails)
   end
   type
end

.ole_type_helpstring(pTypeInfo) ⇒ Object



3123
3124
3125
3126
3127
3128
3129
3130
# File 'lib/win32ole-pr.rb', line 3123

def self.ole_type_helpstring(pTypeInfo)
   bhelpstr = 0.chr * 4
   hr = ole_docinfo_from_type(pTypeInfo, nil, bhelpstr, nil, nil)
   return nil if hr != S_OK
   str = 0.chr * 256
   wcscpy(str,bhelpstr.unpack('L').first)
   wide_to_multi(str)
end

.ole_typedesc2val(pTypeInfo, pTypeDesc, typedetails) ⇒ Object



3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
# File 'lib/win32ole-pr.rb', line 3175

def self.ole_typedesc2val(pTypeInfo,pTypeDesc,typedetails)
   typestr = nil
   vt = pTypeDesc[4,2].unpack('S').first
   case vt
   when VT_I2
      typestr = "I2"
   when VT_I4
      typestr = "I4"
   when VT_R4
      typestr = "R4"
   when VT_R8
      typestr = "R8"
   when VT_CY
      typestr = "CY"
   when VT_DATE
      typestr = "DATE"
   when VT_BSTR
      typestr = "BSTR"
   when VT_BOOL
      typestr = "BOOL"
   when VT_VARIANT
      typestr = "VARIANT"
   when VT_DECIMAL
      typestr = "DECIMAL"
   when VT_I1
      typestr = "I1"
   when VT_UI1
      typestr = "UI1"
   when VT_UI2
      typestr = "UI2"
   when VT_UI4
      typestr = "UI4"
   when VT_I8
      typestr = "I8"
   when VT_UI8
      typestr = "UI8"
   when VT_INT
      typestr = "INT"
   when VT_UINT
      typestr = "UINT"
   when VT_VOID
      typestr = "VOID"
   when VT_HRESULT
      typestr = "HRESULT"
   when VT_PTR
      typestr = "PTR"
      if typedetails
         typedetails.push(typestr)
      end
      return ole_ptrtype2val(pTypeInfo,pTypeDesc,typedetails)
   when VT_SAFEARRAY
      typestr = "SAFEARRAY"
      if typedetails
         typedetails.push(typestr)
      end
      return ole_ptrtype2val(pTypeInfo,pTypeDesc,typedetails)
   when VT_CARRAY
      typestr = "CARRAY"
   when VT_USERDEFINED
      typestr = "USERDEFINED"
      if typedetails
         typedetails.push(typestr)
      end
      str = WIN32OLE_TYPE.ole_usertype2val(pTypeInfo,pTypeDesc,typedetails)
      return str if str
      return typestr
   when VT_UNKNOWN
      typestr = "UNKNOWN"
   when VT_DISPATCH
      typestr = "DISPATCH"
   when VT_ERROR
      typestr = "ERROR"
   when VT_LPWSTR
      typestr = "LPWSTR"
   when VT_LPSTR
      typestr = "LPSTR"
   else
      typestr = "Unknown Type #{vt}"
   end
   if typedetails
      typedetails.push(typestr)
   end
   typestr
end

.ole_usertype2val(pTypeInfo, pTypeDesc, typedetails) ⇒ Object



3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
# File 'lib/win32ole-pr.rb', line 3136

def self.ole_usertype2val(pTypeInfo,pTypeDesc,typedetails)
   lpVtbl = 0.chr * 4
   table = 0.chr * 80
   memcpy(lpVtbl,pTypeInfo,4)
   memcpy(table,lpVtbl.unpack('L').first,80)
   table = table.unpack('L*')
   getRefTypeInfo = Win32::API::Function.new(table[14],'PLP','L')
   p = 0.chr * 4
   hr = getRefTypeInfo.call(pTypeInfo,pTypeDesc.unpack('L').first,p)
   pRefTypeInfo = p.unpack('L').first
   return nil if hr != S_OK
   bstr = 0.chr * 4
   hr = ole_docinfo_from_type(pRefTypeInfo, bstr, nil, nil, nil)
   if hr != S_OK
      WIN32OLE.ole_release(pRefTypeInfo)
      return nil
   end
   WIN32OLE.ole_release(pRefTypeInfo)
   str = 0.chr * 256
   wcscpy(str,bstr.unpack('L').first)
   type = wide_to_multi(str)
   if typedetails
      typedetails.push(type)
   end
   type
end

.progidsObject



2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
# File 'lib/win32ole-pr.rb', line 2825

def self.progids
   progids = []
   hclsids = 0.chr * 4
    err = WIN32OLE_TYPELIB.reg_open_key(HKEY_CLASSES_ROOT, "CLSID", hclsids)
   if err != ERROR_SUCCESS
      return progids
   end
   hclsids = hclsids.unpack('L').first
   i = 0
   while true
      clsid = WIN32OLE_TYPELIB.reg_enum_key(hclsids, i)
      break if clsid.nil?
      hclsid = 0.chr * 4
      err = WIN32OLE_TYPELIB.reg_open_vkey(hclsids, clsid, hclsid)
      if err != ERROR_SUCCESS
         i += 1
         next
      end
      hclsid = hclsid.unpack('L').first
      if (v = WIN32OLE_TYPELIB.reg_get_val2(hclsid, "ProgID"))
         progids.push(v)
      end
      if (v = WIN32OLE_TYPELIB.reg_get_val2(hclsid, "VersionIndependentProgID")) 
         progids.push(v)
      end
      RegCloseKey(hclsid);
   
      i += 1
   end
   RegCloseKey(hclsids)
   progids
end

.typelibsObject



2821
2822
2823
# File 'lib/win32ole-pr.rb', line 2821

def self.typelibs
   WIN32OLE_TYPELIB.typelibs.collect{|t|t.name}
end

Instance Method Details

#default_event_sourcesObject



3430
3431
3432
# File 'lib/win32ole-pr.rb', line 3430

def default_event_sources
   ole_type_impl_ole_types(@pTypeInfo, IMPLTYPEFLAG_FSOURCE|IMPLTYPEFLAG_FDEFAULT)
end

#default_ole_typesObject



3434
3435
3436
# File 'lib/win32ole-pr.rb', line 3434

def default_ole_types
   ole_type_impl_ole_types(@pTypeInfo, IMPLTYPEFLAG_FDEFAULT)
end

#guidObject



2962
2963
2964
# File 'lib/win32ole-pr.rb', line 2962

def guid
   ole_type_guid(@pTypeInfo)
end

#helpcontextObject



3310
3311
3312
# File 'lib/win32ole-pr.rb', line 3310

def helpcontext
   ole_type_helpcontext(@pTypeInfo)
end

#helpfileObject



3299
3300
3301
# File 'lib/win32ole-pr.rb', line 3299

def helpfile
   ole_type_helpfile(@pTypeInfo)
end

#helpstringObject



3132
3133
3134
# File 'lib/win32ole-pr.rb', line 3132

def helpstring
   WIN32OLE_TYPE.ole_type_helpstring(@pTypeInfo)
end

#implemented_ole_typesObject



3422
3423
3424
# File 'lib/win32ole-pr.rb', line 3422

def implemented_ole_types
   ole_type_impl_ole_types(@pTypeInfo,0)
end

#inspectObject



3438
3439
3440
# File 'lib/win32ole-pr.rb', line 3438

def inspect
   "#<#{self.class}:#{self.to_s}>"
end

#major_versionObject



3045
3046
3047
# File 'lib/win32ole-pr.rb', line 3045

def major_version
   ole_type_major_version(@pTypeInfo)
end

#minor_versionObject



3070
3071
3072
# File 'lib/win32ole-pr.rb', line 3070

def minor_version
   ole_type_minor_version(@pTypeInfo)
end

#nameObject Also known as: to_s



2887
2888
2889
# File 'lib/win32ole-pr.rb', line 2887

def name
   @name
end

#ole_methodsObject



3369
3370
3371
# File 'lib/win32ole-pr.rb', line 3369

def ole_methods
   WIN32OLE.ole_methods_from_typeinfo(@pTypeInfo,INVOKE_FUNC | INVOKE_PROPERTYGET | INVOKE_PROPERTYPUT | INVOKE_PROPERTYPUTREF)
end

#ole_ole_type(pTypeInfo) ⇒ Object



2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
# File 'lib/win32ole-pr.rb', line 2892

def ole_ole_type(pTypeInfo)
   type = nil
   lpVtbl = 0.chr * 4
   table = 0.chr * 88
   memcpy(lpVtbl,pTypeInfo,4)
   memcpy(table,lpVtbl.unpack('L').first,88)
   table = table.unpack('L*')
   getTypeAttr = Win32::API::Function.new(table[3],'PP','L')
   releaseTypeAttr = Win32::API::Function.new(table[19],'PP','L')
   p = 0.chr * 4
   hr = getTypeAttr.call(pTypeInfo,p)
   return type if hr != S_OK     
   pTypeAttr = p.unpack('L').first
   typeAttr = 0.chr * 76
   memcpy(typeAttr,pTypeAttr,76)
   typekind = typeAttr[40,4].unpack('L').first
   case typekind
   when TKIND_ENUM
      type = "Enum"
   when TKIND_RECORD
      type = "Record"
   when TKIND_MODULE
      type = "Module"
   when TKIND_INTERFACE
      type = "Interface"
   when TKIND_DISPATCH
      type = "Dispatch"
   when TKIND_COCLASS
      type = "Class"
   when TKIND_ALIAS
      type = "Alias"
   when TKIND_UNION
      type = "Union"
   when TKIND_MAX
      type = "Max"
   else
      type = nil
   end
   releaseTypeAttr.call(pTypeInfo,pTypeAttr)
   type
end

#ole_typeObject



2934
2935
2936
# File 'lib/win32ole-pr.rb', line 2934

def ole_type
   ole_ole_type(@pTypeInfo)
end

#ole_type_guid(pTypeInfo) ⇒ Object



2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
# File 'lib/win32ole-pr.rb', line 2938

def ole_type_guid(pTypeInfo)
   guid = nil
   lpVtbl = 0.chr * 4
   table = 0.chr * 88
   memcpy(lpVtbl,pTypeInfo,4)
   memcpy(table,lpVtbl.unpack('L').first,88)
   table = table.unpack('L*')
   getTypeAttr = Win32::API::Function.new(table[3],'PP','L')
   releaseTypeAttr = Win32::API::Function.new(table[19],'PP','L')
   p = 0.chr * 4
   hr = getTypeAttr.call(pTypeInfo,p)
   return guid if hr != S_OK     
   pTypeAttr = p.unpack('L').first
   typeAttr = 0.chr * 76
   memcpy(typeAttr,pTypeAttr,76)
   bstr = 0.chr * 160
   len = StringFromGUID2(typeAttr[0,16], bstr, 80)
   if len > 3
      guid = wide_to_multi(bstr)
   end
   releaseTypeAttr.call(pTypeInfo,pTypeAttr)
   guid
end

#ole_type_helpcontext(pTypeInfo) ⇒ Object



3303
3304
3305
3306
3307
3308
# File 'lib/win32ole-pr.rb', line 3303

def ole_type_helpcontext(pTypeInfo)
   helpcontext = 0.chr * 4
   hr = WIN32OLE_TYPE.ole_docinfo_from_type(pTypeInfo, nil, nil, helpcontext, nil)
   return nil if hr != S_OK
   helpcontext.unpack('L').first
end

#ole_type_helpfile(pTypeInfo) ⇒ Object



3290
3291
3292
3293
3294
3295
3296
3297
# File 'lib/win32ole-pr.rb', line 3290

def ole_type_helpfile(pTypeInfo)
   bhelpfile = 0.chr * 4
   hr = WIN32OLE_TYPE.ole_docinfo_from_type(pTypeInfo, nil, nil, nil, bhelpfile)
   return nil if hr != S_OK
   str = 0.chr * 256
   wcscpy(str,bhelpfile.unpack('L').first)
   wide_to_multi(str)
end

#ole_type_impl_ole_types(pTypeInfo, implflags) ⇒ Object



3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
# File 'lib/win32ole-pr.rb', line 3377

def ole_type_impl_ole_types(pTypeInfo,implflags)
   types = []
   lpVtbl = 0.chr * 4
   table = 0.chr * 80
   memcpy(lpVtbl,pTypeInfo,4)
   memcpy(table,lpVtbl.unpack('L').first,80)
   table = table.unpack('L*')
   getTypeAttr = Win32::API::Function.new(table[3],'PP','L')
   getRefTypeOfImplType = Win32::API::Function.new(table[8],'PLP','L')
   getImplTypeFlags = Win32::API::Function.new(table[9],'PLP','L')
   getRefTypeInfo = Win32::API::Function.new(table[14],'PLP','L')
   releaseTypeAttr = Win32::API::Function.new(table[19],'PP','L')
   p = 0.chr * 4
   hr = getTypeAttr.call(pTypeInfo,p)
   pTypeAttr = p.unpack('L').first
   return types if hr != S_OK
      
   pTypeAttr = p.unpack('L').first
   typeAttr = 0.chr * 76
   memcpy(typeAttr,pTypeAttr,76)
   for i in 0 ... typeAttr[48,2].unpack('S').first
      flags = 0.chr * 4
      hr = getImplTypeFlags.call(pTypeInfo, i,flags)
      next if hr != S_OK
      flags = flags.unpack('L').first
      href = 0.chr * 4
      hr = getRefTypeOfImplType.call(pTypeInfo, i, href)
      next if hr != S_OK
      href = href.unpack('L').first
      p = 0.chr * 4
      hr = getRefTypeInfo.call(pTypeInfo, href, p)
      next if hr != S_OK
      pRefTypeInfo = p.unpack('L').first
      if (flgas & implflags) == implflags
         type = WIN32OLE.ole_type_from_itypeinfo(pRefTypeInfo)
         if type
            types.push(type)
         end
      end
      WIN32OLE.ole_release(pRefTypeInfo)
   end
   releaseTypeAttr(pTypeInfo, pTypeAttr)
   types
end

#ole_type_major_version(pTypeInfo) ⇒ Object



3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
# File 'lib/win32ole-pr.rb', line 3024

def ole_type_major_version(pTypeInfo)
   lpVtbl = 0.chr * 4
   table = 0.chr * 88
   memcpy(lpVtbl,pTypeInfo,4)
   memcpy(table,lpVtbl.unpack('L').first,88)
   table = table.unpack('L*')
   getTypeAttr = Win32::API::Function.new(table[3],'PP','L')
   releaseTypeAttr = Win32::API::Function.new(table[19],'PP','L')
   p = 0.chr * 4
   hr = getTypeAttr.call(pTypeInfo,p)
   if hr != S_OK     
      raise WIN32OLERuntimeError, "failed to GetTypeAttr"
   end      
   pTypeAttr = p.unpack('L').first
   typeAttr = 0.chr * 76
   memcpy(typeAttr,pTypeAttr,76)
   ver = typeAttr[56,2].unpack('S').first    
   releaseTypeAttr.call(pTypeInfo,pTypeAttr)
   ver
end

#ole_type_minor_version(pTypeInfo) ⇒ Object



3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
# File 'lib/win32ole-pr.rb', line 3049

def ole_type_minor_version(pTypeInfo)
   lpVtbl = 0.chr * 4
   table = 0.chr * 88
   memcpy(lpVtbl,pTypeInfo,4)
   memcpy(table,lpVtbl.unpack('L').first,88)
   table = table.unpack('L*')
   getTypeAttr = Win32::API::Function.new(table[3],'PP','L')
   releaseTypeAttr = Win32::API::Function.new(table[19],'PP','L')
   p = 0.chr * 4
   hr = getTypeAttr.call(pTypeInfo,p)
   if hr != S_OK     
      raise WIN32OLERuntimeError, "failed to GetTypeAttr"
   end      
   pTypeAttr = p.unpack('L').first
   typeAttr = 0.chr * 76
   memcpy(typeAttr,pTypeAttr,76)
   ver = typeAttr[58,2].unpack('S').first    
   releaseTypeAttr.call(pTypeInfo,pTypeAttr)
   ver
end

#ole_type_progid(pTypeInfo) ⇒ Object



2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
# File 'lib/win32ole-pr.rb', line 2966

def ole_type_progid(pTypeInfo)
   progid = nil
   lpVtbl = 0.chr * 4
   table = 0.chr * 88
   memcpy(lpVtbl,pTypeInfo,4)
   memcpy(table,lpVtbl.unpack('L').first,88)
   table = table.unpack('L*')
   getTypeAttr = Win32::API::Function.new(table[3],'PP','L')
   releaseTypeAttr = Win32::API::Function.new(table[19],'PP','L')
   p = 0.chr * 4
   hr = getTypeAttr.call(pTypeInfo,p)
   return progid if hr != S_OK      
   pTypeAttr = p.unpack('L').first
   typeAttr = 0.chr * 76
   memcpy(typeAttr,pTypeAttr,76)
   bstr = 0.chr * 4
   hr = ProgIDFromCLSID(typeAttr[0,16], bstr)
   if hr == S_OK
      str = 0.chr * 256
      wcscpy(str,bstr.unpack('L').first)
      progid = wide_to_multi(str)
      CoTaskMemFree(bstr)
   end
   releaseTypeAttr.call(pTypeInfo,pTypeAttr)
   progid
end

#ole_type_src_type(pTypeInfo) ⇒ Object



3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
# File 'lib/win32ole-pr.rb', line 3260

def ole_type_src_type(pTypeInfo)
   _alias = nil
   lpVtbl = 0.chr * 4
   table = 0.chr * 88
   memcpy(lpVtbl,pTypeInfo,4)
   memcpy(table,lpVtbl.unpack('L').first,88)
   table = table.unpack('L*')
   getTypeAttr = Win32::API::Function.new(table[3],'PP','L')
   releaseTypeAttr = Win32::API::Function.new(table[19],'PP','L')
   p = 0.chr * 4
   hr = getTypeAttr.call(pTypeInfo,p)
   return _alias if hr != S_OK      
   
   pTypeAttr = p.unpack('L').first
   typeAttr = 0.chr * 76
   memcpy(typeAttr,pTypeAttr,76)
   typekind = typeAttr[40,4].unpack('L').first
   if typekind != TKIND_ALIAS    
      releaseTypeAttr.call(pTypeInfo,pTypeAttr)
      return _alias
   end
   _alias = WIN32OLE_TYPE.ole_typedesc2val(pTypeInfo,typeAttr[60,8],nil)
   releaseTypeAttr.call(pTypeInfo,pTypeAttr)
   return _alias
end

#ole_type_typekind(pTypeInfo) ⇒ Object



3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
# File 'lib/win32ole-pr.rb', line 3074

def ole_type_typekind(pTypeInfo)
   lpVtbl = 0.chr * 4
   table = 0.chr * 88
   memcpy(lpVtbl,pTypeInfo,4)
   memcpy(table,lpVtbl.unpack('L').first,88)
   table = table.unpack('L*')
   getTypeAttr = Win32::API::Function.new(table[3],'PP','L')
   releaseTypeAttr = Win32::API::Function.new(table[19],'PP','L')
   p = 0.chr * 4
   hr = getTypeAttr.call(pTypeInfo,p)
   if hr != S_OK     
      raise WIN32OLERuntimeError, "failed to GetTypeAttr"
   end      
   pTypeAttr = p.unpack('L').first
   typeAttr = 0.chr * 76
   memcpy(typeAttr,pTypeAttr,76)
   typekind = typeAttr[40,4].unpack('L').first
   releaseTypeAttr.call(pTypeInfo,pTypeAttr)
   typekind
end

#ole_type_visible(pTypeInfo) ⇒ Object



2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
# File 'lib/win32ole-pr.rb', line 2997

def ole_type_visible(pTypeInfo)
   lpVtbl = 0.chr * 4
   table = 0.chr * 88
   memcpy(lpVtbl,pTypeInfo,4)
   memcpy(table,lpVtbl.unpack('L').first,88)
   table = table.unpack('L*')
   getTypeAttr = Win32::API::Function.new(table[3],'PP','L')
   releaseTypeAttr = Win32::API::Function.new(table[19],'PP','L')
   p = 0.chr * 4
   hr = getTypeAttr.call(pTypeInfo,p)
   return true if hr != S_OK     
   pTypeAttr = p.unpack('L').first
   typeAttr = 0.chr * 76
   memcpy(typeAttr,pTypeAttr,76)
   if (typeAttr[54,2].unpack('S').first & (TYPEFLAG_FHIDDEN | TYPEFLAG_FRESTRICTED)) != 0
      visible = false
   else
      visible = true
   end
   releaseTypeAttr.call(pTypeInfo,pTypeAttr)
   visible
end

#ole_typelibObject



3373
3374
3375
# File 'lib/win32ole-pr.rb', line 3373

def ole_typelib
   WIN32OLE.ole_typelib_from_itypeinfo(@pTypeInfo)
end

#ole_variables(pTypeInfo) ⇒ Object



3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
# File 'lib/win32ole-pr.rb', line 3314

def ole_variables(pTypeInfo)
   variables = []
   lpVtbl = 0.chr * 4
   table = 0.chr * 88
   memcpy(lpVtbl,pTypeInfo,4)
   memcpy(table,lpVtbl.unpack('L').first,88)
   table = table.unpack('L*')
   getTypeAttr = Win32::API::Function.new(table[3],'PP','L')
   getVarDesc = Win32::API::Function.new(table[6],'PLP','L')
   getNames = Win32::API::Function.new(table[7],'PLPLP','L')
   releaseTypeAttr = Win32::API::Function.new(table[19],'PP','L')
   releaseVarDesc = Win32::API::Function.new(table[21],'PP','L')
   p = 0.chr * 4     
   hr = getTypeAttr.call(pTypeInfo,p)
   pTypeAttr = p.unpack('L').first
   if hr != S_OK
      raise WIN32OLERuntimeError, "failed to GetTypeAttr"
   end
   typeAttr = 0.chr * 76
   memcpy(typeAttr,pTypeAttr,76)
   for i in 0 ... typeAttr[46,2].unpack('S').first
      p = 0.chr * 4
      getVarDesc.call(pTypeInfo,i,p)
      pVarDesc = p.unpack('L').first
      next if hr != S_OK
      varDesc = 0.chr * 36
      memcpy(varDesc,pVarDesc,36)
      bstr = 0.chr * 4
      len = 0.chr * 4
      hr = getNames.call(pTypeInfo,varDesc[0,4].unpack('L').first,bstr,1,len)
      if hr != S_OK || len.unpack('L').first == 0 ||
         bstr.unpack('L').first == 0
         next
      end
      
      var = WIN32OLE_VARIABLE.new
      var.pTypeInfo = pTypeInfo
      var.index = i
      bstr = bstr.unpack('L').first
      str = 0.chr * 256
      wcscpy(str,bstr)
      SysFreeString(bstr)
      var.name = wide_to_multi(str)
      variables.push(var)
      releaseVarDesc.call(pTypeInfo,pVarDesc)
      pVarDesc = nil
   end
   releaseTypeAttr.call(pTypeInfo,pTypeAttr)
   variables
end

#oletype_set_member(pTypeInfo, name) ⇒ Object



2811
2812
2813
2814
2815
# File 'lib/win32ole-pr.rb', line 2811

def oletype_set_member(pTypeInfo,name)
   @name = name
   @pTypeInfo = pTypeInfo
   WIN32OLE.ole_addref(pTypeInfo) if pTypeInfo
end

#progidObject



2993
2994
2995
# File 'lib/win32ole-pr.rb', line 2993

def progid
   ole_type_progid(@pTypeInfo)
end

#source_ole_typesObject



3426
3427
3428
# File 'lib/win32ole-pr.rb', line 3426

def source_ole_types
   ole_type_impl_ole_types(@pTypeInfo, IMPLTYPEFLAG_FSOURCE)
end

#src_typeObject



3286
3287
3288
# File 'lib/win32ole-pr.rb', line 3286

def src_type
   ole_type_src_type(@pTypeInfo)
end

#typekindObject



3095
3096
3097
# File 'lib/win32ole-pr.rb', line 3095

def typekind
   ole_type_typekind(@pTypeInfo)
end

#variablesObject



3365
3366
3367
# File 'lib/win32ole-pr.rb', line 3365

def variables
   ole_variables(@pTypeInfo)
end

#visible?Boolean

Returns:

  • (Boolean)


3020
3021
3022
# File 'lib/win32ole-pr.rb', line 3020

def visible?
   ole_type_visible(@pTypeInfo)
end