On Wed, 22 Aug 2012, Philip Prindeville wrote:
> I was originally going to check the list archives before posting, but
> I get a 403 from pipermail on the website, so can't do that.
>
> I'm running ActiveState perl (community version) on Win7-x64 updated,
> and wrote the following simple/stupid test program.
> 
> #!/usr/bin/perl -w
> 
> use strict;
> use warnings;
> 
> sub obj_cb($)
> {
>   my $obj = shift;
>   my $class = Win32::OLE->QueryObjectType($obj);
>   printf STDERR "%s=>%s\n", $obj, $class;
> }
> 
> my $count = Win32::OLE->EnumAllObjects(\&obj_cb);
> 
> printf STDERR "count=%d\n", $count;
> 
> exit 1;
> 
> and running it (both as myself and as Administrator) I get:
> 
> count=0

That is expected, as EnumAllObjects only enumerates instantiated
Win32::OLE objects from inside your process, and you haven't
created any.

> Anyone have a simple/stupid program that detects whatever programs are
> present that are manipulable via OLE?

There is no way to do this.  You could crawl the registry, instantiate all
registered COM objects, and do a QueryInterface for the IDispatch interface.
This doesn't do you much good though, as you still wouldn't know which
methods and properties the object supports.

An alternative is to crawl the registry for all registered type libraries.
That at least gives you all the methods and properties, but I don't think
you can get the ProgID that way.  There is a sample script that does this
though:

http://cpansearch.perl.org/src/JDB/Win32-OLE-0.1709/eg/typelibs.pl

In the end you should just consult the documentation for the object model
of the application you want to automate.  Then just instantiate an application
level object for it, and if that fails, you can assume that the app isn't
(correctly?) installed. :)

Cheers,
-Jan


_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to