473,394 Members | 1,749 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Getting TypeLib ID of a COM dll

Hello!

I need to somehow extract the TypeLib ID from a COM-dll compiled using
VB6. Is is possible or do I have to look it up in the registry somehow
(ie by iterating over TypeLibIDs in HKEY_CLASSES_ROOT\TypeLib\ and
matching the DLL path info?

Please excuse any inaccuracies in this post, my understanding of COM
is patchy, especially the progid/clsid/typelib part of it.

Oct 4 '07 #1
2 3886
To what end do you need to get the type library id? The type library id
is the unique identifier for the TLB/DLL, while the CLSID is for the
individual type in the type library.

Regardless, if you want to get information about the type library, you
can call the LoadTypeLibEx function through the P/Invoke layer. You can use
this to get an instance of the ITypeLib interface in the
System.Runtime.InteropServices.ComTypes namespace.

From there, you have to call the GetLibAttr method on the ITypeLib
interface, getting an IntPtr which points to the structure in memory which
has the type library id. You will have to define the TLIBATTR structure,
and then call the static PtrToStructure method on the Marshal class to get
an instance of it (passing the IntPtr returned to you when you called
GetLibAttr).

Once you have the structure, you can access the guid property on it to
get the type library id. Also, don't forget to call ReleaseTLibAttr,
passing the IntPtr you used to get the TLIBATTR structure, so the memory can
be released.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
<na*******@gmail.comwrote in message
news:11**********************@n39g2000hsh.googlegr oups.com...
Hello!

I need to somehow extract the TypeLib ID from a COM-dll compiled using
VB6. Is is possible or do I have to look it up in the registry somehow
(ie by iterating over TypeLibIDs in HKEY_CLASSES_ROOT\TypeLib\ and
matching the DLL path info?

Please excuse any inaccuracies in this post, my understanding of COM
is patchy, especially the progid/clsid/typelib part of it.

Oct 4 '07 #2
Thank you Nicholas, worked like a charm! :)
The reason I needed to do this was that I was writing a vb5 reference
fixer app. I have several large vb6 solutions (20-30 projects
in each one, all of them with dependencies to eachother) and when one
project breaks the binary compatibility I have to update
references to it. Also different versions of components come from
other developers etc, so the invalid reference problem is something I
have to face daily. Now I have an app that goes through the .vbp file
and updates all dll references to the correct typelib ids. =)

On Oct 4, 5:38 pm, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:
To what end do you need to get the type library id? The type library id
is the unique identifier for the TLB/DLL, while the CLSID is for the
individual type in the type library.

Regardless, if you want to get information about the type library, you
can call the LoadTypeLibEx function through the P/Invoke layer. You can use
this to get an instance of the ITypeLib interface in the
System.Runtime.InteropServices.ComTypes namespace.

From there, you have to call the GetLibAttr method on the ITypeLib
interface, getting an IntPtr which points to the structure in memory which
has the type library id. You will have to define the TLIBATTR structure,
and then call the static PtrToStructure method on the Marshal class to get
an instance of it (passing the IntPtr returned to you when you called
GetLibAttr).

Once you have the structure, you can access the guid property on it to
get the type library id. Also, don't forget to call ReleaseTLibAttr,
passing the IntPtr you used to get the TLIBATTR structure, so the memory can
be released.

--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com

<nasseg...@gmail.comwrote in message

news:11**********************@n39g2000hsh.googlegr oups.com...
Hello!
I need to somehow extract the TypeLib ID from a COM-dll compiled using
VB6. Is is possible or do I have to look it up in the registry somehow
(ie by iterating over TypeLibIDs in HKEY_CLASSES_ROOT\TypeLib\ and
matching the DLL path info?
Please excuse any inaccuracies in this post, my understanding of COM
is patchy, especially the progid/clsid/typelib part of it.- Hide quoted text -

- Show quoted text -

Oct 8 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: jwsacksteder | last post by:
I am trying to extend Crystal Reports with Python. The documented way to do this is to create a COM automation server with a specific naming convention that CR will then present inside the UI as...
2
by: Alexander Eisenhuth | last post by:
Hello alltogether, I hope somebody can help me in that case. I bet I have overseen s.th.. I have a VC++ IDispatch Com-Server (ATL) and include for error handling issues a enumeration in the...
12
by: Vince C. | last post by:
Hi, I've created a web application with Visual Interdev and I've added Microsoft XML, version 4 in project's references. A META tag has been successfully added in global.asa: <!--METADATA...
1
by: Thomas Born | last post by:
Hi; I use following code in an ASP page to generate a GUID: <% dim obj Set obj = Server.CreateObject("Scriptlet.TypeLib") Response.Write(obj.guid) Set obj = nothing %>
2
by: Eyal | last post by:
Hey, I would appriciate if anyone can help on this one: I have a java object/inteface having a method with a boolean parameter. As I'm trying to call this method from a javascript it fails on...
0
by: Nathan Baulch | last post by:
I have a windows app that has a few Interop assemblies. If I run it on a machine that doesn't have the required COM libraries, I get nasty COMExceptions. What I would like to do is check to see...
2
by: Jeff Van Epps | last post by:
We've been unable to get events working going from C# to VJ++. We think that the C# component is being exposed properly as a ConnectionPoint, and the Advise() from the VJ++ side seems to be...
7
by: TJ | last post by:
In C# how do you achieve pass-by-reference property declarations in the Type Library? I am writing a COM Class Library that must mimick an existing library for which the only information is the...
3
by: winkatl1213 | last post by:
Hello, I am working with comtypes to interface Microsoft's DirectShow library. First, I found a Type Library on the internet that was created for accessing DirectShow from .NET. It seems that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.