Re: How to get an OLE array of objects in Perl?



While I have some rudimentary knowledge in Perl, I don't
think it's sufficient for your purposes... Anyway, from the
OLE side you probably want a VARIANT with the following
type: VT_BYREF | VT_ARRAY | VT_DISPATCH. This is a reference
to a safe array of IDispatch pointers. How you construct the
safe array in Perl is beyond me, however...

Note this is an untypical argument to pass to such a method.
Normally a C++ client would pass a pointer to an uninitilized
VARIANT for the method to fill in. Therefore this might not
work at all. FWIW the method signature itself is unfriendly
for non-C++ developers...

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnickolov@xxxxxxxx
MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================

<kingskippus@xxxxxxxxx> wrote in message
news:1155931922.368652.16910@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I'm really scratching my head over this. I posted it over in a Perl
group hoping someone familiar with OLE could help, and now I'm posting
it here hoping someone here might be familiar with Perl and can help.

I have an OLE object with a method that takes an [out] parameter (a
parameter that gets changed within the OLE object method) that is an
array of other OLE objects. What I'd like to do is to get that array
of other OLE objects and iterate through them, printing out a property
from each one. I don't know that much about OLE objects, can someone
please help? I've been Googling for hours and feel like I'm close, but
I can't find anything for that last little bit.

Here's what I need using semi-pseudocode that I know won't work right:

use Win32::OLE;
my $tree = Win32::OLE->new( 'Tree.Component' );
my @nodes;

# GetNodes is a method of TreeComponent that is defined like this:
# int GetNodes([out] TreeNode[])
# where TreeNode is another OLE object type

$tree->GetNodes(\@nodes); # This doesn't work...
for $node (@nodes) {
print $node->{Name}."\n"; # Name is a property of TreeNode objects

}

No error or warning is generated, but the @nodes array doesn't have any
elements in it. However, I do know it has elements, because I've
tested this function in another utility, and it returns 89 TreeNode
objects.

Here's a piece of code that I found on another site that the author
claims to work, but not quite for what I need. This code gets a double
back:

use Win32::OLE;
use Win32::OLE::Variant;
my $arg4 = Variant( VT_R8 | VT_BYREF, 0.0);
my $service = Win32::OLE->new( '3rdPartyComponent.Service' );
$service->foo( 31, 4000, 28000, $arg4 );
# That last parameter is a double, whose value gets altered within
# and passed back out of the foo method of the $service object.

...But I don't want doubles, I want an array of OLE objects, and not
being very familiar with OLE, I'm totally stumped. I *think* that the
answer is that I have to pass some kind of Variant to the function.
That's what this guy does to get a double value passed out of the OLE
method that takes an [out] parameter. But if I do that, what kind of
Variant do I pass in? And how do I get access to the OLE objects I get
back?

I sure would appreciate any help anyone can give me on this!



.



Relevant Pages

  • Re: [VC6] Passing Visual Basic 6 arrays via SAFEARRAY
    ... The limiting factor are the OLE marshalling routines. ... The code to properly type-check your variant is as follows: ... // We only take an array of Single/float ... >Automation server. ...
    (microsoft.public.vc.mfc)
  • Re: Powerpoint/Word 2008 sound issue
    ... welcome to the wonderful world of OLE objects. ... OLE is a feature of Windows. ... On the Mac, Microsoft Office has implemented limited support for OLE. ...
    (comp.sys.mac.apps)
  • Re: How to get embedded OLE objects out
    ... There are several ways to store images in OLE Object fields. ... The main alternatives are to work with images in the filesystem, or images in the database (as raw-binary/blob ... Some additional info on OLE Embedding vs raw-binary/blob storage is available here: ... Image Handling Components, Samples, Solutions and Info DBPix 2.0 - lossless jpeg rotation, EXIF, asynchronous "Aaron" wrote:>The database I am working with has lot's of graphic files embedded in the>database as OLE objects. ...
    (microsoft.public.access.macros)
  • How to get an OLE array of objects in Perl?
    ... I posted it over in a Perl ... I have an OLE object with a method that takes an parameter (a ... What I'd like to do is to get that array ... of other OLE objects and iterate through them, ...
    (microsoft.public.win32.programmer.ole)
  • Re: How to read pictures from a document and save to picture type file by the way of using VBA?
    ... THe code was desinged to work with Word Picture objects not OLE objects. ... and find the bmp file is only a black color ...
    (microsoft.public.word.drawing.graphics)