http://qs1969.pair.com?node_id=234310

chinman has asked for the wisdom of the Perl Monks concerning the following question:

Purveyors of Perl Wisdom,

I'm trying to access a Win32 DLL using the Win32 OLE module. Some test code is shown below.

#!/usr/bin/perl -w #xcalibur automation test script use strict; use Win32::OLE; use Win32::OLE::Const 'XRawfile2 1.0 Type Library'; #specify a data file and create the object my $rawFile = 'C:\Xcalibur\Data\oligo01.raw'; my $XRawfile = new Win32::OLE('Xrawfile.XRawfile.1') or die "yikes, ca +n't instantiate object\n"; #read back the object my $obj = Win32::OLE->QueryObjectType($XRawfile); #this line returns "IXRawfile", everything appears ok print "object type = $obj\n"; #open a file into the XRawfile object $XRawfile->Open("$rawFile"); #this line seems to indicate everything is ok as it doesn't return an +error test_for_error(); #try to readback the file we just loaded #alas this appears to suck pond water - doesn't work my $filename = ""; $XRawfile->GetFileName($filename); test_for_error(); print "the file is: $filename\n"; #sub that prints an error if encountered sub test_for_error { my $error = Win32::OLE->LastError(); print $error if $error; }

Basically, it looks like I can create the object ok (line 15). I also think that I'm opening the rawfile ok (line 23), since no errors are returned. I can't seem to get the other methods to work. I think, the problem is that the other methods associated with this DLL require the variables to be pointers. For example, the GetFileName method that I've attempted to implement above actually appears to require a pointer to a string. For example, the function call from the OLEview for the GetFileName method is:

void GetFileName(BSTR* pbstrFileName);

Is there a way to implement these calls with Win32::OLE, or do I need to use the Win32::API or Win32::API::Prototype? Some of the other methods require pointers to longs, doubles, or variants. Any thoughts (or pointers) would be greatly appreciated.

Regards,
chinman