473,659 Members | 3,592 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_RO OT\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 3904
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.co m
<na*******@gmai l.comwrote in message
news:11******** **************@ n39g2000hsh.goo glegroups.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_RO OT\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.guar d.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.c om

<nasseg...@gmai l.comwrote in message

news:11******** **************@ n39g2000hsh.goo glegroups.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_RO OT\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
1189
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 user functions. That was easy enough to start, but apparently you need to register your code in type libraries as well. I have been unable to make ANY progress on that front. I have a an IDL document that I was able to compile with MIDL.EXE and...
2
3527
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 IDL-File. enum PROG_ERROR { P_OK = 0,
12
3088
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 TYPE="TypeLib" NAME="Microsoft XML, v4.0" UUID="{F5078F18-C551-11D3-89B9-0000F81FE221}" VERSION="4.0"--> But when I write the following code in an ASP server-side JavaScript:
1
4134
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
6907
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 a type mismatch. It is positively because of the boolean(java primitive)parameter. It goes fine if I change this parameter to int or String. This inteface has a lot more methods which works fine, it is just the
0
328
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 if the required libraries are registered when first starting my app. As I couldn't find an easy way to do this, I thought I might just get the Identities of each of the ActiveX type assembly references using reflection and look them up in...
2
1733
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 working, because the delegate on the C# side has 1 item in its invocation list after the Advise(). However when we try to make the callback, we get: System.NullReferenceException: Object reference not set to an instance of an object at...
7
3889
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 TypeLib. I'm using Visual Studio .NET 2003. The original library provides simple authentication services, from Access and MS-SQL OLEDB providers. The enhancement I'm creating provides support for ODBC and will be a drop-in replacement.
3
3300
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 DirectShow only comes with IDL files and no type library. This got me started.
0
8337
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8531
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8628
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5650
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2754
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1978
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1739
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.