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

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

问题描述

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

但是,这不是一个很好的过程.将来我是否需要这样做,是否可以使用命令行从.exe提取Type Lib(.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:\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也在敲门.

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天全站免登陆