[EMAIL PROTECTED] wrote:
> Hi List,
>
> I am using Win32::OLE to access a custom COM interface
> (Secure FTP Server by GlobalSCAPE). Mostly I have been successful
> after much reading, experimentation and gnashing of teeth but
> how to retrieve a VARIANT array totally escapes me. The only interface
> description I have is this IDL:
>
> Returns an array of allowed IP masks.
> HRESULT GetAllowedMasks([out,retval] VARIANT *aMasks);
>
> The array aMasks may be any size and (I assume) contains
> VT_BSTR elements such as 'nnn.nnn.nnn.nnn-nnn' where
> any or all octets may contain a range separated by a hyphen.
>
> I can instantiate the server object and do good things with simple
> data types such as VT_BSTR and VT_BOOL :
>
> # For example, this will add an IP mask:
> $ServerObj = Win32::OLE->new( 'COMInterface.CIServer');
> my $bstrMask = Win32::OLE->Variant->(VT_BSTR, '111.112.113.114-119');
> my $boolTrue = Win32::OLE->Variant->(VT_BOOL, 1);
> $ServerObj ->AddIPAccessRule($bstrMask,$boolTrue);
> $ServerObj ->ApplyuChanges();
> $ServerObj ->close();
>
> But I have been totally unsuccessful in retrieving the array containing the
> IP Masks.
> At this point I'm not even sure what the code should look like, arrrgh.
> Unfortunately,
> there is a lot of the Win32::OLE doc that is over my head! Any help,
> examples,
> links, etc. will really be appreciated.
You're probably going to need a 'by reference' variant, but Jan's the
expert here and may pick up on your post. Maybe something like
VT_VARIANT|VT_BYREF or VT_ARRAY|VT_VARIANT|VT_BYREF will do what you
need. I just don't have the experience with variants to give an exact
answer.
Variant.pm:
Variants by reference
Some OLE servers expect parameters passed by reference so that they
can be changed in the method call. This allows methods to easily
return multiple values. There is preliminary support for this in
the Win32::OLE::Variant module:
my $x = Variant(VT_I4|VT_BYREF, 0);
my $y = Variant(VT_I4|VT_BYREF, 0);
$Corel->GetSize($x, $y);
print "Size is $x by $y\n";
After the C<GetSize> method call C<$x> and C<$y> will be set to
the respective sizes. They will still be variants. In the print
statement the overloading converts them to string representation
automatically.
VT_BYREF is now supported for all variant types (including SAFEARRAYs).
It can also be used to pass an OLE object by reference:
my $Results = $App->CreateResultsObject;
$Object->Method(Variant(VT_DISPATCH|VT_BYREF, $Results));
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs