如何使用 IGlobalInterfaceTable 传递接口指针? [英] How to use IGlobalInterfaceTable to pass an interface pointer?

查看:21
本文介绍了如何使用 IGlobalInterfaceTable 传递接口指针?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  • 没有:
    • MFC
    • ATL

    问题:

    • What are the steps involved, to use IGlobalInterfaceTable, when passing a particular interface pointer to several threads using CreateThread?

    推荐答案

    我认为 这个页面 很好地涵盖了它.调用 RegisterInterfaceInGlobal 将您的 COM 接口放入 GIT,将其 cookie 传递给您的其他线程,然后可以使用该 cookie 调用 GetInterfaceFromGlobal 以获取原始接口.

    I think this page covers it rather well. Call RegisterInterfaceInGlobal to put your COM interface in the GIT, pass its cookie to your other threads, which can then call GetInterfaceFromGlobal using that cookie to get the original interface.

    请注意,每个线程都必须调用 CoCreateInstance(CLSID_StdGlobalInterfaceTable......但别担心,它们都会获得一个指向同一 GIT 实例的接口指针.

    Note that each thread has to call CoCreateInstance(CLSID_StdGlobalInterfaceTable... but don't worry, they all get an interface pointer to the same instance of the GIT.

    这篇关于如何使用 IGlobalInterfaceTable 传递接口指针?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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