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

Hi, I am trying to use Win32 OLE to call a function that retrieves an array of bytes. This function expects a VARIANT pointer like the following. Read(int address, unsigned short bySize, VARIANT *byData); And the Perl code is as follows.
use Win32::OLE; use Win32::OLE::Variant; my $re = Win32::OLE->new('Read.ReadService') || die("Unable to open Re +adService ", Win32::OLE->LastError()); #Variables my $dat; my $temp; #$dat = Variant(VT_UI1|VT_ARRAY|VT_BYREF, 1); $dat = Variant(VT_EMPTY, 1); $re->Read(0xE0000, 13, $dat); foreach $temp ($dat) { print "0x".$temp; }
I have tried many different ways to pass the variant but no luck. Can anyone point me to the right way to pass the variant to retrieve the data back? Any suggestions would be very helpful? Thanks.

Replies are listed 'Best First'.
Re: Trouble retrieving array of bytes using OLE
by Corion (Patriarch) on Dec 06, 2010 at 17:54 UTC

    What is the output of your program?

    foreach is not the way to iterate over a Variant array. See Win32::OLE qw( in ).

      Is the way the Variant is passed to return data from the OLE function correct?
Re: Trouble retrieving array of bytes using OLE
by eforperl (Initiate) on Dec 06, 2010 at 17:39 UTC
    Hi Monks, Can anyone help with this issue? Thanks.