如何在VS C ++中使用.tlb类型创建接口方法? [英] How do I create interface methods using .tlb types in VS C++?

查看:154
本文介绍了如何在VS C ++中使用.tlb类型创建接口方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景:


  1. .TLB文件包含用X语言编写的接口。我没有.h,.idl,.tlh或任何其他头文件 - 只是.TLB文件。语言'X'不导出兼容的.h,.idl等。

  2. 我使用VS向导添加一个ATL简单对象到我的ATL项目。

我想向我的简单ATL对象的接口添加一个方法,该方法使用一个.TLB定义的类型作为参数。

I want to add a method to the interface of my simple ATL object that uses one of the .TLB defined types for a parameter.

// Something like the following in the .idl file:
interface ISomeInterface : IUnknown {
   HRESULT SomeMethod([in] ITypeFromTLB* aVal); // ITypeFromTLB declared in .TLB file.
};

我该如何做?我希望一个向导,或在.idl接口声明中的一行,将带来.tlb信息。 midl的include(没有.tlb),import(没有tlb)和importlib(只有库)似乎不提供解决方案(我需要 proxy / stub工作,所以我不能把这个在库声明中使用importlib命令)。

How can I do this? I'm hoping for a wizard, or a line in the .idl interface declaration that would bring in the .tlb information. midl's include (no .tlb), import (no tlb), and importlib (library only) don't seem to provide a solution (I need proxy/stub to be working, so I cannot put this inside the library declaration with the importlib command).

推荐答案

使用#import 在cpp / h中,将TLB界面带到您的命名空间。

Use #import in cpp/h to bring TLB interfaces to your namespace.

这篇关于如何在VS C ++中使用.tlb类型创建接口方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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