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

Hi monks. I'm trying to use a COM object that someone else wrote. One particular interface has a method that looks like this:
void getMemberNames( [out] SAFEARRAY(BSTR)* aNameArray);
I have an interface pointer, and I'd like to call this method, but I'm not sure how to specify the safearray of BSTRs. I'm thinking I need to use the Win32::OLE::Variant with VT_ARRAY|VT_BSTR, but other than that I'm not quite sure. Could someone point me in the right direction? Thanks, Michael

Replies are listed 'Best First'.
Re: Win32::OLE and SAFEARRAYs
by Jenda (Abbot) on Jun 26, 2003 at 19:06 UTC

    I think it has to be VT_ARRAY|VT_BSTR|VT_BYREF. I believe you'll need to do something like:

    my $array = Variant(VT_ARRAY|VT_BSTR|VT_BYREF, $length); $obj->getMemberNames( $array);

    Jenda
    Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.
       -- Rick Osborne

    Edit by castaway: Closed small tag in signature