com - 如何将 .tlb 文件转换为 header 和实现文件?

标签 com idl mscorlib typelib clr-hosting

我正在尝试转换 mscorlib.tlb。 它通常在 C++ 中使用如下:

#import "mscorlib.tlb" raw_interfaces_only              \
     high_property_prefixes("_get","_put","_putref")        \
     rename("ReportEvent", "InteropServices_ReportEvent")

如何将其转换为 header 和实现文件?

我能够使用 Visual Studio 编译一个包含上述行的虚拟 cpp 文件,并生成一个 .tlh 文件。难道不应该还有实现文件吗?

最佳答案

您可以通过在 #import 中使用“no_implementation”和“implementation_only”参数来拆分实现和声明。它们生成 .tlh(类型库头)和 .tli(类型库实现)文件。

我通常将以下内容放入头文件中(如 stdafx.h):

#import "C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorlib.tlb" no_implementation

并将以下内容写入 .cpp 文件(如 stdafx.cpp):

#import "C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorlib.tlb" implementation_only

关于com - 如何将 .tlb 文件转换为 header 和实现文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6461218/

相关文章:

c++ - CComPtr 和引用计数

c++ - COM:如何将特定类型的 COM 对象指定为 idl 中的参数

c# - 编译错误CS0305 使用泛型类型List

.net - System.Runtime (.net 4.6) 和 mscorlib (.net Standard 1.6)

.net - edge.js:如何使用对 COM 对象的引用从 .NET 程序集中调用方法?

c++ - 如果我在 IMFTransform 上有指针,如何获取 GUID 编码器?

c# - COM 互操作在 Release模式下失败

c++ - 无需重新编译即可更改 CORBA 接口(interface)

html - WHATWG html5标准文档中idl属性是什么意思?

.net - 使用 PerfView 检测内存泄漏