Forum: Ruby win32ole, integer pointer parameter

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.
B4a8eee1710af2dd36fee8ff4c0772a5?d=identicon&s=25 Graham Ford (Guest)
on 2006-06-08 19:00
(Received via mailing list)
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 ='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.

E97181961afa48102e3a28daab69b904?d=identicon&s=25 Masaki Suketa (Guest)
on 2006-06-11 13:53
(Received via mailing list)

In message "win32ole, integer pointer parameter"
    on 06/06/09, "Graham Ford" <> writes:
> rc = engine.Execute('C:\path\to\dir',0,retVal)
> print "Return Code: ",retVal

How about WIN32OLE::ARGV ?

  print "Return Code: ", WIN32OLE::ARGV[2]

  Masaki Suketa
This topic is locked and can not be replied to.