# Win32Ole question

**URL:** <https://www.ruby-forum.com/t/win32ole-question/84808>\
**Category:** Ruby\
**Created:** [February 7, 2007, 9:18pm UTC](https://www.ruby-forum.com/t/win32ole-question/84808 "2007-02-07T21:18:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![NationS\_Carey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/87869e/32.png) [@NationS\_Carey](https://www.ruby-forum.com/u/NationS_Carey)\
**Post date:** [February 7, 2007, 9:18pm UTC](https://www.ruby-forum.com/t/win32ole-question/84808/1 "2007-02-07T21:18:37Z")

</div>

Hi,

I need to do the functional equivalent of a QueryInterface. I have an  
object but I need access to methods in another interface that it  
supports. How can I do that?

Thanks!

* * *

Carey Nation [mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

Software Engineer

Turner Broadcasting System, Inc

Internet Technologies

(404)827-2935 (wk)

(404)824-0033 (cell)

---

<div class="post-metadata">

**Author:** ![NationS\_Carey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/87869e/32.png) [@NationS\_Carey](https://www.ruby-forum.com/u/NationS_Carey)\
**Post date:** [February 7, 2007, 11:17pm UTC](https://www.ruby-forum.com/t/win32ole-question/84808/2 "2007-02-07T23:17:54Z")

</div>

On 2/7/07, Nation, Carey [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi,
> 
> I need to do the functional equivalent of a QueryInterface. I have an  
> object but I need access to methods in another interface that it  
> supports. How can I do that?

AFAIK, Win32OLE can’t do that (at least in Ruby 1.8 branch). There’s a  
patch pending in the tracker  
([http://rubyforge.org/tracker/?func=detail&atid=1700&aid=8437&group\_id=426](http://rubyforge.org/tracker/?func=detail&atid=1700&aid=8437&group_id=426))  
that you can apply to sources and compile yourself, if you don’t want  
to wait for it to be applied. In that case, please report any problems  
back to the tracker.

You’ll find more details in the patch comments (Masaki S. is the  
maintainer of WIN32OLE).

---

<div class="post-metadata">

**Author:** ![NationS\_Carey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/87869e/32.png) [@NationS\_Carey](https://www.ruby-forum.com/u/NationS_Carey)\
**Post date:** [February 8, 2007, 4:24pm UTC](https://www.ruby-forum.com/t/win32ole-question/84808/3 "2007-02-08T16:24:30Z")

</div>

Ah, ok, thanks. Guess I’m a little dense. I couldn’t find anything  
about how to apply the patch. Can you point me at something?

Thanks!

---

<div class="post-metadata">

**Author:** ![NationS\_Carey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/87869e/32.png) [@NationS\_Carey](https://www.ruby-forum.com/u/NationS_Carey)\
**Post date:** [February 8, 2007, 11:21pm UTC](https://www.ruby-forum.com/t/win32ole-question/84808/4 "2007-02-08T23:21:21Z")

</div>

On 2/8/07, Nation, Carey [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Ah, ok, thanks. Guess I’m a little dense. I couldn’t find anything  
> about how to apply the patch. Can you point me at something?
> 
> Thanks!

So, here we go:

You’ll need:

1. ruby-oneclick installed
2. msvc6 installed
3. the patch from the tracker
4. (optionally) the patch program

This is how to proceed:

1. copy the patch where the sources of win32ole are  
(c:/ruby/src/ruby-1.8.xxx/ext/win32ole
2. patch the source:  
2.a (if you have the patch program):  
patch -p2 \< ruby-1.8-changes.patch  
2.b otherwise: just copy the + lines into appropriate place (you have  
a bit of context, and line numbers to find the place)
3. start a console (cmd)
4. run vcvars32.bat from ms vc bin dir (I don’t know the exact place,  
look it up. It might be named a bit different though). This will setup  
the compile environment.
5. run from the win32ole directory extconf.rb That should check  
available libs and headers, and prepare a Makefile.
6. now start the compilation: nmake
7. if everything went ok, you’ll have a brand new win32ole.so. Copy it  
to c:/ruby/lib/1.8/i386-mswin32/ and you’re done.

Notes:

- It should be possible to use mingw gcc compiler, but I don’t know how.
- You should rather try the compilation with unpatched file, e. g. do  
this once without step 2. to see if you’re able to compile.
- There might be an easier way to do all of this, but you have to ask  
wiser men 😉  
Basically, you need to google for two things: 1. how to compile a ruby  
extension and 2. how to patch a file
- Beware that the patch is untested, so it may (the author says so) or  
may not work.
