中度。为什么回调 c++将方法添加到 idl 后接口未更新?
我尝试使用 COM 技术实现回调接口,并具有这样的 IDL:
library LogstreamScannerLib
{
importlib("stdole2.tlb");
[
uuid(8CACF064-EF0E-4496-92D5-F26C64A5858A)
]
dispinterface _IMyClassEvents
{
properties:
methods:
[id(1)] void SomeMethod([in] int data);
};
[
uuid(AFC03FCD-01A9-4F38-994F-BA98E57FF64E)
]
coclass MyComClass
{
[default] interface IMyClass;
[default, source] dispinterface _IMyClassEvents;
};
};
请注意,IMyClass 有 SomeMethod 声明,但我无法弄清楚为什么当我重新编译/重建项目时它没有出现在我的自动生成的类中。
它总是被声明为空:
MIDL_INTERFACE("8CACF064-EF0E-4496-92D5-F26C64A5858A")
_IMyClassEvents : public IDispatch
{
};
我在这里做错了什么?
I try to implement callback interface with COM techonlogy and have IDL like that:
library LogstreamScannerLib
{
importlib("stdole2.tlb");
[
uuid(8CACF064-EF0E-4496-92D5-F26C64A5858A)
]
dispinterface _IMyClassEvents
{
properties:
methods:
[id(1)] void SomeMethod([in] int data);
};
[
uuid(AFC03FCD-01A9-4F38-994F-BA98E57FF64E)
]
coclass MyComClass
{
[default] interface IMyClass;
[default, source] dispinterface _IMyClassEvents;
};
};
Please note, IMyClass has SomeMethod declaration but I can't figure out why doesn't it appear in my auto generated classes when I recompile/rebuild project.
It's always declared as empty:
MIDL_INTERFACE("8CACF064-EF0E-4496-92D5-F26C64A5858A")
_IMyClassEvents : public IDispatch
{
};
What I do wrong here ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我假设你的意思是使用 COM 连接点?以下是 MSDN 中的 ATL 连接点 文档的链接。
如果您想了解如何生成事件代理类,请查看 向对象添加连接点,这里是用于添加事件的 MSDN 教程。您可以根据需要多次重新生成事件代理类。
我发现我总是必须去寻找生成代理类的位置......
I assume you mean using COM Connection Points? Here is a link to the ATL Connection Points documentation in MSDN.
If you are trying to figure out how to generate the event proxy class, look at point 4 in the Adding Connection Points to an Object and here is a MSDN tutorial for adding a event. You can regenerate the event proxy classes as many times as you like.
What I find is that I always have to go looking for where to generate the proxy classes...
最后,我发现了问题所在。
当您使用“实现连接点向导”时,您应该选择从“类型库”(而不是“IDL”)生成连接点。您在组合框中看到此选项,并且应该更改默认选项 IDL ->类型库。
Finally, I have found the issue.
When you use "Implement Connection Point Wizard" you should choose generate connection point from "Type Library" (instead of "IDL"). You see this choice in combobox and should change default option IDL -> Type Lib.