Ask a Question related to PERL Modules, Design and Development.
-
bubbabubbs@yahoo.com #1
Q: ActivePerl - calling an ActiveX object
I 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?
bubbabubbs@yahoo.com Guest
-
ActiveX component can't create object
I'm having problems setting up a monstrous COM+ Frankenapp on my local machine. The application works on the development server when I access it... -
3rd Party ActiveX Object not working
I have been able to use a 3rd Party ActiveX object in a ASP.NET (using ASPCOMPAT=TRUE and impersonation), .NET C# Windows (form) application and... -
Calling a MFC ActiveX Control from a ASP.net web service.
I am looking for some information about a problem I have run into. I have a third party MFC ActiveX Control and I would like to wrap it with a... -
Calling Acrobat file from WScript.Shell ActiveX object
WinXP, Acrobat 6 When I type the name of a PDF file at the Windows command prompt, the file opens properly. Then I create the following JavaScript... -
problems calling ActiveX control inside VB OCX from ASP
I seem to have run into two documented bugs whose workarounds are incompatible. What I have is an OCX written in VB 6 that has a few classes in it.... -
A. Sinan Unur #2
Re: Q: ActivePerl - calling an ActiveX object
[email]bubbabubbs@yahoo.com[/email] wrote in news:1154481724.075186.314530
@i42g2000cwa.googlegroups.com:
Given that we have no idea what this component is, it is hard to come up> I 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.)
with specific recommendations. I'll make some general comments below.
use strict;> Here is my ActivePerl script (slightly simplified):
>
> ################################################## ##############
use warnings;
Win32::OLE->Option(Warn => 3);> use Win32::OLE;
> use Win32::OLE::Const 'Microsoft ActiveX Data Objects';
open my $log_fh, '>', $sLogFileName> my $sLogFileName = "log.txt";
> open( LOG, ">$sLogFileName" );
or die "Cannot open '$sLogFileName': $!";
my $arg4 = 0.0;> $arg4 = 0.0;
print $log_fh "before: $arg4\n";> my $service = Win32::OLE->new( '3rdPartyComponent.Service' );
> print LOG "before: " . $arg4 . "\n";
I seriously doubt the service provides a method named 'foo'. There is no> $service->foo( 31, 4000, 28000, \$arg4 );
way for us to determine if you are using the correct method.
It is possible the higher warning setting for Win32::OLE will give some
useful information.
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
comp.lang.perl.misc guidelines on the WWW:
[url]http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html[/url]
A. Sinan Unur Guest
-
bubbabubbs@yahoo.com #3
Re: Q: ActivePerl - calling an ActiveX object
Sinan:
Thanks for your feedback. I made the code changes you suggested, but am
still not getting correct results from the ActiveX object. But I am not
getting any errors/warnings, either.
You are right, the method is not called 'foo', but something different.
I was hesitant, however, to provide the the method's real name in the
code snippet, as I'm not supposed to reveal proprietary information.
But I'm 100% sure aI am calling the right method.
What the method does is it implements a simple formula like arg4 =
(arg1-X)*arg2/arg3. At least that's what I've been able to figure out
by running some test cases and having the knowledge of the problem
domain. You are probably going to ask: "why don't you just implement
the formula in your code and forget about using the ActiveX object?" I
wish I could, but I can't... long story... the client and the 'suits'
insists on me using the ActiveX object.
Thanks
A. Sinan Unur wrote:> [email]bubbabubbs@yahoo.com[/email] wrote in news:1154481724.075186.314530
> @i42g2000cwa.googlegroups.com:
>>> > I 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.)
> Given that we have no idea what this component is, it is hard to come up
> with specific recommendations. I'll make some general comments below.
>
>>> > Here is my ActivePerl script (slightly simplified):
> >
> > ################################################## ##############
> use strict;
> use warnings;
>>> > use Win32::OLE;
> > use Win32::OLE::Const 'Microsoft ActiveX Data Objects';
> Win32::OLE->Option(Warn => 3);
>>> > my $sLogFileName = "log.txt";
> > open( LOG, ">$sLogFileName" );
> open my $log_fh, '>', $sLogFileName
> or die "Cannot open '$sLogFileName': $!";
>>> > $arg4 = 0.0;
> my $arg4 = 0.0;
>>> > my $service = Win32::OLE->new( '3rdPartyComponent.Service' );
> > print LOG "before: " . $arg4 . "\n";
> print $log_fh "before: $arg4\n";
>>> > $service->foo( 31, 4000, 28000, \$arg4 );
> I seriously doubt the service provides a method named 'foo'. There is no
> way for us to determine if you are using the correct method.
>
> It is possible the higher warning setting for Win32::OLE will give some
> useful information.
>
> Sinan
> --
> A. Sinan Unur <1usa@llenroc.ude.invalid>
> (remove .invalid and reverse each component for email address)
>
> comp.lang.perl.misc guidelines on the WWW:
> [url]http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html[/url]bubbabubbs@yahoo.com Guest
-
Ben Morrow #4
Re: Q: ActivePerl - calling an ActiveX object
Quoth [email]bubbabubbs@yahoo.com[/email]:Perl supports it for calling Perl subs, but Win32::OLE does not. You> I 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.
need to use explicit Variants: see the section at the end of
Win32::OLE::Variant "Variants by reference".
Ben
--
Giles: It's very common for Indian spirits to change to animal form.
Buffy: [...] and, 'Native American'. G: Sorry? B: We don't say 'Indian'.
G: Oh, right, yes; always behind on the terms... yes, still trying not to refer
to you lot as 'bloody colonials'. [Buffy, 'Pangs'] [email]benmorrow@tiscali.co.uk[/email]
Ben Morrow Guest
-
bubbabubbs@yahoo.com #5
Re: Q: ActivePerl - calling an ActiveX object
Ok, I figured it out. This is how you do it:
my $arg4 = Variant( VT_R8 | VT_BYREF, 0.0); # !!!!
my $service = Win32::OLE->new( '3rdPartyComponent.Service' );
$service->foo( 31, 4000, 28000, $arg4 );
bubbabubbs@yahoo.com Guest
-
A. Sinan Unur #6
Re: Q: ActivePerl - calling an ActiveX object
[email]bubbabubbs@yahoo.com[/email] wrote in news:1154555107.290341.146720
@i42g2000cwa.googlegroups.com:
First off, thank you very much for sharing the solution. I am sure knowing> Ok, I figured it out. This is how you do it:
>
> my $arg4 = Variant( VT_R8 | VT_BYREF, 0.0); # !!!!
> my $service = Win32::OLE->new( '3rdPartyComponent.Service' );
> $service->foo( 31, 4000, 28000, $arg4 );
that will help me some time in the future.
I would like to point out, however, that it is useful to leave some
context in your post so others can also understand what you figured out.
See the posting guidelines for this group.
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
comp.lang.perl.misc guidelines on the WWW:
[url]http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html[/url]
A. Sinan Unur Guest



Reply With Quote

