Page 1 of 1 1
Topic Options
#126737 - 2004-09-15 05:24 PM How to find typelib from object...
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
I'm working on a method of automatically importing constants and enums.

I'm looking for a way to get from the object to the typelib, for example
"word.document" -> "c:\program files\Microsoft Office\Office10\MSWORD.OLB"

I just can't see how to associate the registry entries.

Top
#126738 - 2004-09-15 06:11 PM Re: How to find typelib from object...
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
well...
.olb is not typelib, is it?
_________________________
!

download KiXnet

Top
#126739 - 2004-09-15 07:20 PM Re: How to find typelib from object...
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
that be it i think

word.document\CLSID = {00020906-0000-0000-C000-000000000046}

HKEY_CLASSES_ROOT\CLSID\{00020906-0000-0000-C000-000000000046}\TYPELIB =
{00020905-0000-0000-C000-000000000046}

HKEY_CLASSES_ROOT\TypeLib\{00020905-0000-0000-C000-000000000046}\8.2\0\win32\default =
C:\Program Files\MSOffice\Office10\MSWORD.OLB

-Shawn

Top
#126740 - 2004-09-15 08:13 PM Re: How to find typelib from object...
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
k, what that olb stands for?
office library?
_________________________
!

download KiXnet

Top
#126741 - 2004-09-15 08:48 PM Re: How to find typelib from object...
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
guess so,

but I don't think we've answered Richard's question ... the problem is - given any PROGID, determine the typelib, no matter what the class. Think they're are a few more steps we're missing - that 8.x keyname stuff is specific to Office, must be other routes to this value, that aren't package specific.

Top
#126742 - 2004-09-15 09:01 PM Re: How to find typelib from object...
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
well, I can't comment as don't have that stuff.
thus, it's not specific to office but specific to office10 (xp or what the heck it was)
_________________________
!

download KiXnet

Top
#126743 - 2004-09-15 09:27 PM Re: How to find typelib from object...
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Here's a pretty good knowledgebase:

INFO: Registry Entries Made by an ActiveX Component

But checked quickly, think this office stuff breaks the rules a little bit - not totally sure.

Btw - one of the KB references is to Dale Rogerson's "Inside COM" book ... he's the MS COM guru and this is (debatably) the "COM Bible", kinda like the K&R of COM.

-Shawn

Top
#126744 - 2004-09-16 05:25 AM Re: How to find typelib from object...
Stevie Offline
Starting to like KiXtart
*****

Registered: 2002-01-09
Posts: 199
These are the basic steps I'm using in AdminScriptEditor to provide COM "ScriptComplete", which of course requires getting the typelib from a known progid:

  • Call CLSIDFromProgID to get the CLSID corresponding to the Prog ID
  • Read HKEY_CLASSES_ROOT\CLSID\<CLSID of the Component>\Typelib key
  • If the above value exists, read its default value. This value will be the GUID representing the typelibrary.
  • Once you get the GUID representing the typelibrary, read the default value of HKEY_CLASSES_ROOT\Typelib\<GUID representing the
    typelibrary>\<Version>\<Sub Version>\win32
  • This default value will be the full path to the typelibrary
  • If you do not find the Typelib key under HKEY_CLASSES_ROOT\CLSID\<CLSID of the Component> in Step 2, read the default value of one of the following:
    HKEY_CLASSES_ROOT\CLSID\<CLSID of the Component>\InprocServer (for 16 bit DLLs)
    HKEY_CLASSES_ROOT\CLSID\<CLSID of the Component>\InprocServer32 (for 32 bit DLLs)
    HKEY_CLASSES_ROOT\CLSID\<CLSID of the Component>\LocalServer (for 16 bit EXEs)
    HKEY_CLASSES_ROOT\CLSID\<CLSID of the Component>\LocalServer32 (for 32 bit EXEs)


Like Shawn points out, though, this procedure doesn't work in every case. The immediate exceptions that come to mind are the office exe's and several of the VBScript-specific ProgIDs. This should cover the vast majority, though.

I actually contacted MS COM development team on this and they told me there's no way to guarantee the result with this method. If you're asking specifically about how to absolutely account for these exception types, to my knowledge the only way to do it is a less-than-ideal hack. In your example, however, IIRC, the result is the same path and filename except the extension is .exe. So, if the resulting file is an .exe you can check the same directory for an .olb file with the same name and if you find it query the typelib from there. Again, certainly not an ideal solution, but will get you close. IIRC, some of the Office exe and olb files were not even in the same directory, but I can't remember which apps and Office versions those were--so in those cases there's no resolution.

If you find something that is a bit more concrete I would love to know about it.

HTH


Edited by Stevie (2004-09-16 05:38 AM)
_________________________
Stevie

Top
#126745 - 2004-09-16 11:56 AM Re: How to find typelib from object...
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
k, looking in my typelib branch, this 8.2 stuff you talking about is nothing unusual.
all typelibs give somekind of version number there.
so, what is the difficulty in that?
_________________________
!

download KiXnet

Top
#126746 - 2004-09-17 10:13 AM Re: How to find typelib from object...
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Quote:

k, looking in my typelib branch, this 8.2 stuff you talking about is nothing unusual.
all typelibs give somekind of version number there.
so, what is the difficulty in that?




Getting the version number so that you can read the right key

Sorry I haven't updated, had to be somewhere else yesterday.

I thought that I'd gone through all the GUID / key combinations and hadn't got a consistantly working result.

I'll work through the suggestions and let you know how I get on.

Top
#126747 - 2004-09-17 01:41 PM Re: How to find typelib from object...
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
well, mostly there is only one version, that makes it rare to have problems with it.
k, have to dig deeper...
_________________________
!

download KiXnet

Top
Page 1 of 1 1


Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 248 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.062 seconds in which 0.024 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org