如何从 Win32 DLL 或 OCX 中提取 GUID

发布于 2024-09-03 00:48:18 字数 146 浏览 1 评论 0原文

我们有一个 .NET 应用程序需要检查可能包含 COM 库(DLL 和 OCX)的文件夹。当我们遇到 COM 库时,我们需要完成的一件事是从 COM DLL 或 OCX 中提取 GUID。

有没有一种直接的方法可以在 .NET 中执行此操作而不使用第 3 方库?

We have a .NET app that needs to examine a folder that may contain COM libraries (DLL and OCX.) When we do encounter a COM library one thing we need to accomplish is to extract the GUID from the COM DLL or OCX.

Is there a straightforward way to do this with .NET without using 3rd party libraries?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

我做我的改变 2024-09-10 00:48:18

这应该对你有用。它需要引用 c:\windows\system32\tlbinf32.dll,但我假设这没问题,因为它不是第三方组件。

Imports TLI 'from c:\windows\system32\tlbinf32.dll

Dim reglib As TLI.TLIApplication = New TLI.TLIApplicationClass()
Dim DLLPath As String = "c:\mycomponent.ocx"
MsgBox(reglib.TypeLibInfoFromFile(DLLPath).GUID.ToString())

This should work for you. It requires a reference to c:\windows\system32\tlbinf32.dll, but I'm assuming that is okay because it isn't a third party component.

Imports TLI 'from c:\windows\system32\tlbinf32.dll

Dim reglib As TLI.TLIApplication = New TLI.TLIApplicationClass()
Dim DLLPath As String = "c:\mycomponent.ocx"
MsgBox(reglib.TypeLibInfoFromFile(DLLPath).GUID.ToString())
っ〆星空下的拥抱 2024-09-10 00:48:18

您必须使用互操作(P/Invoke 和 COM)才能执行此操作。首先,您必须调用 LoadTypeLib 来获取 ITypeLib 接口对于类型库。

从那里,您必须使用该方法来获取库的 GUID,或者获取库中定义的任何内容的 CLSID 或 IID 实例。

You will have to use interop (both P/Invoke and COM) in order to do this. First, you will have to call the LoadTypeLib to get the ITypeLib interface for the type library.

From there, you will have to use the methods on that in order to get the GUID for the library, or get the CLSID or IID instances for anything defined in the library.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文