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 Val: ".$retVal;
-- end Perl
In ruby I think it should look like this:
-- begin Ruby
require 'win32ole'
engine = WIN32OLE.new('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.
Thanks,
Graham