Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: How to find GUID of Typelibrary for a given OLE Object?

by barbie (Deacon)
on Mar 30, 2005 at 14:02 UTC ( #443457=note: print w/ replies, xml ) Need Help??


in reply to How to find GUID of Typelibrary for a given OLE Object?

I believe the following is the kind of thing you're after:

package Typelibs; use warnings; use strict; use Win32::OLE::Const; # list of all registered type libraries my @Library; Win32::OLE::Const->EnumTypeLibs(sub { my ($clsid,$title,$version,$langid,$filename) = @_; return unless $version =~ /^([0-9a-fA-F]+)\.([0-9a-fA-F]+)$/; my ($maj,$min) = (hex($1), hex($2)); push @Library, [$clsid,$title,$maj,$min,$langid,$filename]; }); sub ExistsTypeLib { my $typelib = shift; for my $lib (@Library) { return @$lib if($lib->[1] =~ /^$typelib/); } return undef; } 1;

You can then call TypeLibs::ExistsTypeLib('Microsoft Excel') and it should return a list consisting of the ClassID, Title, Major Version Number, Minor Version Number, LanguageID, and Executable Filename.

I now have a modified version to check whether Outlook is installed for my Outlook CPAN modules.

--
Barbie | Birmingham Perl Mongers user group | http://birmingham.pm.org/


Comment on Re: How to find GUID of Typelibrary for a given OLE Object?
Download Code
Re^2: How to find GUID of Typelibrary for a given OLE Object?
by barbie (Deacon) on Mar 30, 2005 at 14:04 UTC
    Ooops. Actually the return undef should be return () in this instance.

    --
    Barbie | Birmingham Perl Mongers user group | http://birmingham.pm.org/

Re^2: How to find GUID of Typelibrary for a given OLE Object?
by Anonymous Monk on Mar 30, 2005 at 14:54 UTC
    Thank you for your sample, but your code won't return anything for 'Excel.Application' (since the type library in question is named 'Microsoft Excel 9.0 Object Library'.. Do you have any other ideas?
      This is the PROGID, which doesn't appear to be returned by Win32::OLE. However you could cheat and add the following to the previous code:
      sub ApplicationTypeLib { my $typelib = shift; $typelib =~ s/\.Application//; for my $lib (@Library) { return @$lib if($lib->[1] =~ /$typelib/); } return (); }

      --
      Barbie | Birmingham Perl Mongers user group | http://birmingham.pm.org/

        Thanks for your answer! Is this hack GUARANTEED to work for any ActiveX object name (i.e. is this naming scheme a some form of a standard)? (I mean is there anything regarding this in OLE specs)? Can I rely on this hack in my code?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://443457]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (9)
As of 2014-09-16 10:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (7 votes), past polls