# WIN32OLE type binding

**URL:** <https://www.ruby-forum.com/t/win32ole-type-binding/170119>\
**Category:** Ruby\
**Created:** [June 12, 2009, 3:00pm UTC](https://www.ruby-forum.com/t/win32ole-type-binding/170119 "2009-06-12T15:00:52Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![bdamour](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/7feea3/32.png) [@bdamour](https://www.ruby-forum.com/u/bdamour)\
**Post date:** [June 12, 2009, 3:00pm UTC](https://www.ruby-forum.com/t/win32ole-type-binding/170119/1 "2009-06-12T15:00:52Z")

</div>

Hi,

My COM Web Browser is making progress…  
I can scan COM API, get and set properties value.

The next step is to permit RPC on methods.

Ruby reflexivity let me know :

- the list of methods for an object,
- parameters and their types for each method.

Now I seek for introspection about type binding between Ruby and COM…  
I looked at the documentation where I see we can get all COM  
classes…but not what I want. Here is an example of what I’m looking  
for :

BSTR =\> String  
I4 =\> Fixnum  
F8 =\> Float  
…

does anybody got an advice?

---

<div class="post-metadata">

**Author:** ![bdamour](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/7feea3/32.png) [@bdamour](https://www.ruby-forum.com/u/bdamour)\
**Post date:** [June 12, 2009, 3:11pm UTC](https://www.ruby-forum.com/t/win32ole-type-binding/170119/2 "2009-06-12T15:11:45Z")

</div>

On Fri, Jun 12, 2009 at 9:00 AM, Bruno Le  
hyaric[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi,
> 
> My COM Web Browser is making progress…  
> I can scan COM API, get and set properties value.
> 
> The next step is to permit RPC on methods.

Can you clarify your question a little bit? I’m not sure whether  
you’re asking how to call methods on an WIN32OLE object that are  
provided by a DLL, or if you’re looking for introspection that will  
provide a methods signature…

-greg

---

<div class="post-metadata">

**Author:** ![bdamour](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/7feea3/32.png) [@bdamour](https://www.ruby-forum.com/u/bdamour)\
**Post date:** [June 12, 2009, 5:05pm UTC](https://www.ruby-forum.com/t/win32ole-type-binding/170119/3 "2009-06-12T17:05:22Z")

</div>

Gregory B. wrote:

> On Fri, Jun 12, 2009 at 9:00 AM, Bruno Le  
> hyaric[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > Hi,
> > 
> > My COM Web Browser is making progress…  
> > I can scan COM API, get and set properties value.
> > 
> > The next step is to permit RPC on methods.
> 
> Can you clarify your question a little bit? I’m not sure whether  
> you’re asking how to call methods on an WIN32OLE object that are  
> provided by a DLL, or if you’re looking for introspection that will  
> provide a methods signature…
> 
> -greg

Ok, I have a graphic interface from wich I want to call COM methods.  
By introspection I know the signature of methods.  
The problem is that my interface (a web page) only permits text input.  
So all values I enter are Strings. I need to cast or interpret strings  
to match parameters types…

I solve the problem for put properties like that :

# obj : COM object

# prop : name of the property

# value : string value I want to put

def cast\_from\_string(obj,prop,value)

#call the get property, only to know the type of the Ruby object  
type = obj.send prop.to\_sym

#match on Ruby types and convert the string accordingly…  
case type  
when Integer  
return value.to\_i  
when Float  
return value.to\_f  
when TrueClass, FalseClass  
return value == true.to\_s  
else  
return value  
end  
end

So I want to convert String to the matching Ruby type  
To do that, I need to have a list of COM types and their matched Ruby  
types.  
I wonder if there is that information somewhere in WIN32OLE…

I take a screenshot of the web page so you can have an better idea on  
what I’m trying to do 🙂

---

<div class="post-metadata">

**Author:** ![bdamour](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/7feea3/32.png) [@bdamour](https://www.ruby-forum.com/u/bdamour)\
**Post date:** [June 12, 2009, 5:24pm UTC](https://www.ruby-forum.com/t/win32ole-type-binding/170119/4 "2009-06-12T17:24:30Z")

</div>

On Fri, Jun 12, 2009 at 11:05 AM, Bruno Le  
hyaric[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> So I want to convert String to the matching Ruby type  
> To do that, I need to have a list of COM types and their matched Ruby  
> types.  
> I wonder if there is that information somewhere in WIN32OLE…
> 
> I take a screenshot of the web page so you can have an better idea on  
> what I’m trying to do 🙂

> Attachments:  
> [http://www.ruby-forum.com/attachment/3813/screen.JPG](http://www.ruby-forum.com/attachment/3813/screen.JPG)

Oh I see, when you said COM Web Browser I thought you meant something  
like building your own browser calling out to IE.  
You literally meant browsing COM objects on the web. Interesting  
idea… do you plan to open source this?

Unfortunately, I’m a bit of a WIN32OLE newb and this takes me a bit  
out of my element. So maybe someone else can help you here.

---

<div class="post-metadata">

**Author:** ![bdamour](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/7feea3/32.png) [@bdamour](https://www.ruby-forum.com/u/bdamour)\
**Post date:** [June 13, 2009, 3:43am UTC](https://www.ruby-forum.com/t/win32ole-type-binding/170119/5 "2009-06-13T03:43:28Z")

</div>

2009/6/13 Masaki S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> The only way is reading win32ole.c(ole\_variant2val() and  
> ole\_val2variant()).

Or reading my translation win32ole.rb at  
[http://121.78.227.9/win32-ole/win32ole.rb](http://121.78.227.9/win32-ole/win32ole.rb)

Regards,  
Park H.

---

<div class="post-metadata">

**Author:** ![bdamour](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/7feea3/32.png) [@bdamour](https://www.ruby-forum.com/u/bdamour)\
**Post date:** [June 13, 2009, 3:28am UTC](https://www.ruby-forum.com/t/win32ole-type-binding/170119/6 "2009-06-13T03:28:11Z")

</div>

Hello,

Bruno Le hyaric wrote:

> So I want to convert String to the matching Ruby type  
> To do that, I need to have a list of COM types and their matched Ruby  
> types.  
> I wonder if there is that information somewhere in WIN32OLE…

Sorry, but there is no way to get that information from Win32OLE.  
The only way is reading win32ole.c(ole\_variant2val() and  
ole\_val2variant()).

Regards,  
Masaki S.
