# WIN32OLE in ruby windows one click installer

**URL:** <https://www.ruby-forum.com/t/win32ole-in-ruby-windows-one-click-installer/84426>\
**Category:** Ruby\
**Created:** [February 4, 2007, 9:09am UTC](https://www.ruby-forum.com/t/win32ole-in-ruby-windows-one-click-installer/84426 "2007-02-04T09:09:30Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![shin\_guey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a8b319/32.png) [@shin\_guey](https://www.ruby-forum.com/u/shin_guey)\
**Post date:** [February 4, 2007, 9:09am UTC](https://www.ruby-forum.com/t/win32ole-in-ruby-windows-one-click-installer/84426/1 "2007-02-04T09:09:30Z")

</div>

Hello,

I am new to ruby for programming win32ole. I install ruby on windows  
using ruby one click installer windows version 1.8.5-21. I check the  
win32ole.c inside the src/ruby-1.8.5/ext/win32ole directory and the  
version shows in the file is only version 0.6.6. But I found in the ruby  
trunk the the current win32ole version is 0.9.2.

My question is how do I check my win32ole ext for my current ruby  
installer?  
How do I compile with the newer version? I can compile my current source  
using:  
ruby extconf.rb  
nmake  
nmake install  
But it doesn’t work with the latest version of win32ole I downloaded. It  
has errors when I try to compile win32ole version 0.9.2.

The second question is I am having problem on using my current win32ole  
ext, I am suspecting it could be the version is too old already.Is it  
any workaround for this? I want to run the following function generate  
using olegen.rb.

# VOID FindAllAvmc

# method FindAllAvmc

# DeviceInfo,DeviceInfo arg0 — avmcList [OUT]

def FindAllAvmc(arg0)  
ret = @dispatch.\_invoke(2, [arg0], [VT\_BYREF|VT\_ARRAY|VT\_DISPATCH])  
@lastargs = WIN32OLE::ARGV  
ret  
end

The cpp for the function is :  
STDMETHODIMP Avmc::FindAllAvmc(SAFEARRAY \*\*avmcList)  
// avmcList is array of structures: devinfo

When I try to run:  
C:\ruby\src\ruby-1.8.5\ext\win32ole\sample\>irb  
irb(main):001:0\> require ‘avmc’  
=\> true  
irb(main):002:0\> avmc = AvmcIfc\_Avmc\_1.new  
=\> #\<AvmcIfc\_Avmc\_1:0x2efe488 @dispatch=#WIN32OLE:0x2efe438,  
@progid=“AvmcIfc.  
Avmc.1”, @clsid="{41BDBDFC-A848-4523-A149-ADD3AE1E6D84}"\>  
irb(main):003:0\> dev = []  
=\> []  
irb(main):004:0\> avmc.FindAllAvmc(dev)  
WIN32OLERuntimeError: \_invoke  
OLE error code:0 in   
  
HRESULT error code:0x80020005  
Type mismatch.  
from ./avmc.rb:39:in `_invoke' from ./avmc.rb:39:in`FindAllAvmc’  
from (irb):4  
irb(main):005:0\>  
irb(main):005:0\> dev = 0  
=\> 0x00  
irb(main):006:0\> avmc.FindAllAvmc(dev)  
TypeError: wrong argument type Fixnum (expected Array)  
from ./avmc.rb:39:in `_invoke' from ./avmc.rb:39:in`FindAllAvmc’  
from (irb):6  
irb(main):007:0\>

Any idea on how to solve this problem? I am wonder the newer version of  
win32ole will solve this problem. Seems like the new version include the  
WIN32OLE\_VARIANT .

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![shin\_guey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a8b319/32.png) [@shin\_guey](https://www.ruby-forum.com/u/shin_guey)\
**Post date:** [February 4, 2007, 9:37am UTC](https://www.ruby-forum.com/t/win32ole-in-ruby-windows-one-click-installer/84426/2 "2007-02-04T09:37:00Z")

</div>

Hello,

In message “WIN32OLE in ruby windows one click installer”  
on 07/02/04, shin guey [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

> How do I compile with the newer version? I can compile my current source  
> using:  
> ruby extconf.rb  
> nmake  
> nmake install  
> But it doesn’t work with the latest version of win32ole I downloaded. It  
> has errors when I try to compile win32ole version 0.9.2.

The Win32OLE version 0.9.2 comes with Ruby 1.9.0 (or later).  
And the Ruby version of ruby trunk is 1.9.0.  
You can’t compile Win32OLE version 0.9.2 with Ruby 1.8.5.  
You need Ruby 1.9.0 to compile Win32OLE version 0.9.2.

Regards,  
Masaki S.

---

<div class="post-metadata">

**Author:** ![shin\_guey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a8b319/32.png) [@shin\_guey](https://www.ruby-forum.com/u/shin_guey)\
**Post date:** [February 4, 2007, 11:25am UTC](https://www.ruby-forum.com/t/win32ole-in-ruby-windows-one-click-installer/84426/3 "2007-02-04T11:25:33Z")

</div>

Masaki S. wrote:

> Hello,
> 
> In message “WIN32OLE in ruby windows one click installer”  
> on 07/02/04, shin guey [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:
> 
> > How do I compile with the newer version? I can compile my current source  
> > using:  
> > ruby extconf.rb  
> > nmake  
> > nmake install  
> > But it doesn’t work with the latest version of win32ole I downloaded. It  
> > has errors when I try to compile win32ole version 0.9.2.
> 
> The Win32OLE version 0.9.2 comes with Ruby 1.9.0 (or later).  
> And the Ruby version of ruby trunk is 1.9.0.  
> You can’t compile Win32OLE version 0.9.2 with Ruby 1.8.5.  
> You need Ruby 1.9.0 to compile Win32OLE version 0.9.2.
> 
> Regards,  
> Masaki S.

Hi,

From the latest version, it shows that it has fix some VT\_ARRAY bugs.  
So, do I need the new version to use my com dll?

Anyway, thanks for the quick reply.

Regards,  
Shin Guey

---

<div class="post-metadata">

**Author:** ![shin\_guey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a8b319/32.png) [@shin\_guey](https://www.ruby-forum.com/u/shin_guey)\
**Post date:** [February 5, 2007, 12:01pm UTC](https://www.ruby-forum.com/t/win32ole-in-ruby-windows-one-click-installer/84426/4 "2007-02-05T12:01:18Z")

</div>

In message “Re: WIN32OLE in ruby windows one click installer”  
on 07/02/04, Shin guey Wong [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

> > From the latest version, it shows that it has fix some VT\_ARRAY bugs.  
> > So, do I need the new version to use my com dll?

Ruby 1.9.0 is not the stable version, neither Win32OLE(especially  
WIN32OLE\_VARIANT features).  
So, try at your own risk.  
I am not sure, but I’m afraid that the new version might not  
work in your situation…

Before you try the new version, could you try the following with  
the current version?

def FindAllAvmc(arg0)  
# specify VT\_BYREF|VT\_ARRAY|VT\_VARIANT instead of  
# VT\_BYREF|VT\_ARRAY|VT\_DISPATCH  
ret = @dispatch.\_invoke(2, [arg0], [VT\_BYREF|VT\_ARRAY|VT\_VARIANT])  
@lastargs = WIN32OLE::ARGV  
ret  
end

Regards,  
Masaki S.

---

<div class="post-metadata">

**Author:** ![shin\_guey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a8b319/32.png) [@shin\_guey](https://www.ruby-forum.com/u/shin_guey)\
**Post date:** [February 6, 2007, 1:04pm UTC](https://www.ruby-forum.com/t/win32ole-in-ruby-windows-one-click-installer/84426/5 "2007-02-06T13:04:41Z")

</div>

Masaki S. wrote:

> Before you try the new version, could you try the following with  
> the current version?
> 
> def FindAllAvmc(arg0)  
> # specify VT\_BYREF|VT\_ARRAY|VT\_VARIANT instead of  
> # VT\_BYREF|VT\_ARRAY|VT\_DISPATCH  
> ret = @dispatch.\_invoke(2, [arg0], [VT\_BYREF|VT\_ARRAY|VT\_VARIANT])  
> @lastargs = WIN32OLE::ARGV  
> ret  
> end
> 
> Regards,  
> Masaki S.

I had tried to use the code above. It still not working, I am getting  
the same error message:  
irb(main):004:0\> avmc.FindAllAvmc(dev)  
WIN32OLERuntimeError: \_invoke  
OLE error code:0 in   
  
HRESULT error code:0x80020005  
Type mismatch.  
from ./avmc.rb:39:in `_invoke' from ./avmc.rb:39:in`FindAllAvmc’  
from (irb):4

Thanks for you reply. I will try to install the new ruby 1.9 on other  
machine and try again. I had been using this dll on C# and python. Both  
is working fine. May be I also need to look into the source code…but I  
am really not familiar with windows com dll programming. It seems like  
too many specification on it.

Regards,  
Shin Guey

---

<div class="post-metadata">

**Author:** ![shin\_guey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a8b319/32.png) [@shin\_guey](https://www.ruby-forum.com/u/shin_guey)\
**Post date:** [February 10, 2007, 3:26pm UTC](https://www.ruby-forum.com/t/win32ole-in-ruby-windows-one-click-installer/84426/6 "2007-02-10T15:26:18Z")

</div>

Sorry for being too late to reply.  
And I had not noticed important thing to ask you.

In message “Re: WIN32OLE in ruby windows one click installer”  
on 07/02/06, Shin guey Wong [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

> Thanks for you reply. I will try to install the new ruby 1.9 on other  
> machine and try again. I had been using this dll on C# and python. Both  
> is working fine. May be I also need to look into the source code…but I  
> am really not familiar with windows com dll programming. It seems like  
> too many specification on it.

How can I get the dll(source code)?  
Using the dll, I’d like to investigate this problem.

Regards,  
Masaki S.
