如何在命令行上从 COM exe 中提取 TypeLib

发布于 2024-10-05 07:02:11 字数 264 浏览 4 评论 0原文

我最近需要生成一个互操作程序集。经过一番谷歌搜索后,我发现了 tlbimp.exe。我的下一个问题是我的 COM 库没有附带 .tlb 文件。进一步的谷歌搜索显示,类型库通常作为资源包含在 exe/dll 中。果然,在 VS2010 中打开 exe,发现它的类型是 lib,然后右键单击,我得到了一个可与 tlbimp 一起使用的 tlb 文件。惊人的。

然而,这不是一个很好的过程。如果我将来需要这样做,有没有办法使用命令行从 .exe 中提取类型库(.tlb 文件)?

I've recently had need to produce an interop assembly. After some googling I discovered tlbimp.exe. My next problem was that my COM library did not come with a .tlb file. Further googling revealed that the type lib is often included as a resource in an exe/dll. Sure enough, opening the exe in VS2010 revealed it's type lib and a right-click later I had a tlb file to use with tlbimp. Awesome.

However this is not a very nice process. Should I need to do this in the future, is there a way of extracting a Type Lib (.tlb file) from a .exe using the command line?

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

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

发布评论

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

评论(1

梦在深巷 2024-10-12 07:02:11

Tlbimp.exe 可以很好地处理 EXE 内的类型库资源。例如:顺便说一句

C:\temp\temp>tlbimp c:\windows\system32\wiaacmgr.exe
Microsoft (R) .NET Framework Type Library to Assembly Converter 3.5.30729.1
Copyright (C) Microsoft Corporation.  All rights reserved.

Type library imported to WIAACMGRLib.dll

,自动化这是相当危险的。类型库与程序集引用非常等效。如果它改变了,你想知道它。不仅仅是因为您可能必须修改互操作代码并重新测试它,DLL Hell 也正在敲您的门。

Tlbimp.exe can handle a type library resource inside an EXE just fine. For example:

C:\temp\temp>tlbimp c:\windows\system32\wiaacmgr.exe
Microsoft (R) .NET Framework Type Library to Assembly Converter 3.5.30729.1
Copyright (C) Microsoft Corporation.  All rights reserved.

Type library imported to WIAACMGRLib.dll

Automating this is fairly risky btw. A type library is quite equivalent to an assembly reference. If it changed you want to know about it. Not just because you may well have to modify your interop code and retest it, DLL Hell is knocking on your door as well.

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