Win32Ole question

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:[email protected]

Software Engineer

Turner Broadcasting System, Inc

Internet Technologies

(404)827-2935 (wk)

(404)824-0033 (cell)

On 2/7/07, Nation, Carey [email protected] 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)
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).

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!

On 2/8/07, Nation, Carey [email protected] 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 :wink:
    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.