From: George Thomas on

I am trying to call a method in an ATL (C++ based) dll created by myself
through WIN32OLE of Ruby

The signature of the method in the idl file is something as follows

[id(37), helpstring("method GetCustomArea")] HRESULT GetCustomArea([out]
LONG* UpperLeft_XCord, [out] LONG* UpperLeft_YCord, [out] LONG* Width,
[out] LONG* Height, [out,retval] VARIANT_BOOL* ReturnVal);

In Ruby I have tried something as follows..

require 'win32ole'
a ="IDof the component")
c = a.GetCustomArea(nil,nil,nil,nil)

Further querying the value as(for the first out paramter)
WIN32OLE::ARGV[0] does not give me a valid result.

I have also tried something as follows..

require 'win32ole'
a ="IDof the component")
dispid = a.ole_method('GetCustomArea').dispid
a._invoke(dispid, [nil,nil,nil,nil,nil], [VT_I4|VT_BYREF,
The error in this case is

WIN32OLERuntimeError: (in OLE method '<dispatch id:37: )
OLE error code:0 in <Unknown>
<No Description>
Invalid number of parameters.
from (irb): 5: in '_invoke'
from C:/................../bin/irb:12:in '<main>'

Can some one point me in the right direction? I have several other
methods in my component. All others are working fine. However , they do
not have an [out] parameter.

Posted via

From: arton on

With _invoke, you may set the initial values in the second
argument as same type as specified in the third argument,
and don't include for [retval].
So, please try to write as
a._invoke(dispid, [0,0,0,0],