Q: ActivePerl - calling an ActiveX object
am 02.08.2006 03:22:04 von bubbabubbsI have a 3rd-party ActiveX object (as a DLL) that I am trying to call
from Perl (ActivePerl 5.8) The function that I am calling takes three
'in' parameters, and returns the result via the fourth 'out'
parameter. So I need to pass the last parameter by reference, which I
know Perl supports. (Unfortunately, the 3rd party cannot/will not
modify the interface.)
Here is my ActivePerl script (slightly simplified):
############################################################ ####
use Win32::OLE;
use Win32::OLE::Const 'Microsoft ActiveX Data Objects';
my $sLogFileName = "log.txt";
open( LOG, ">$sLogFileName" );
$arg4 = 0.0;
my $service = Win32::OLE->new( '3rdPartyComponent.Service' );
print LOG "before: " . $arg4 . "\n";
$service->foo( 31, 4000, 28000, \$arg4 );
print LOG " after: " . $arg4 . "\n";
$arg4 = 1.0;
my $service2 = Win32::OLE->new( '3rdPartyComponent.Service' );
print LOG "before: " . $arg4 . "\n";
$service2->foo( 31, 4000, 28000, \$arg4 );
print LOG " after: " . $arg4 . "\n";
close(LOG);
############################################################ ####
Output from the script (log.txt):
before: 0
after: 0
before: 1
after: 1
I'm not getting any runtime errors, but $arg4 is not getting altered
after calling $service2->foo(). I know for the fact that after foo()
the value of $arg4 should be ~79.7 Also, I have tried calling the
ActiveX object from C++, and it works as expected. But the project
I'm working on requires me to use Perl. Does anyone have any ideas as
to what I am doing wrong.
I admit that I don't have a lot of experience with Perl, and am
learning as I go.
TIA
P.S. Is there a more appropriate newsgroup to post this to?