Forum: Ruby Win32OLE, COM, pointer arguments

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
14a39b1c665d705fa4104cb088d2fa1d?d=identicon&s=25 Graham Ford (graham)
on 2006-06-08 18:35
I am trying to call a COM DLL with Win32OLE, but I am running into an
issue with passing an argument to the method call.  The following works
in Perl:

-- begin Perl

use Win32::OLE;
use Win32::OLE::Variant;

my $engine = Win32::OLE->new('X.X') or die 'Cannot load engine DLL:
my $system = 'C:\path\to\dir';
my $mode = 0;
my $retVal = Variant(VT_I4|VT_BYREF, 0);
my $rc;

$rc = $engine->Execute($system,$mode,$retVal);
print "Return Code: ".Win32::OLE->LastError."\n";
print "Return Val: ".$retVal;

-- end Perl

In ruby I think it should look like this:

-- begin Ruby

require 'win32ole'
engine ='X.X')

retVal = 1
rc = 1

rc = engine.Execute('C:\path\to\dir',0,retVal)

print "Return Code: ",retVal

-- end Ruby

When I run the ruby code, the DLL executes and processes the directory,
but I need to be able to get back the return value.  Unlike in Perl,
ruby doesn't seem to be able to generate a variant object to be passed
to the method call.  The DLL expects an integer pointer for the third
argument, COM signature VT_I4|VT_BYREF, but I'm at a loss as to how to
properly pass this so I can retrieve the value after execution.

I've also tried olegen.rb to generate a ruby class for the DLL, but this
seems to have the same exact problem.

This topic is locked and can not be replied to.