如何在命令行上从 COM exe 中提取 TypeLib [英] How to Extract TypeLib from a COM exe on Command Line

查看:15
本文介绍了如何在命令行上从 COM exe 中提取 TypeLib的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

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

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?

推荐答案

Tlbimp.exe 可以很好地处理 EXE 中的类型库资源.例如:

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

C:	emp	emp>tlbimp c:windowssystem32wiaacmgr.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 也在敲您的门.

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.

这篇关于如何在命令行上从 COM exe 中提取 TypeLib的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆