如何从 C++ 使用 WndProc dll?

发布于 2024-08-01 18:10:43 字数 248 浏览 1 评论 0原文

我想处理来自 DLL 的一些 SAPI 消息,DLL 是某种插件。 如何处理 VC++ dll 内的消息/事件。 SAPI 事件处理如以下示例所示: http://msdn.microsoft.com/en-我们/库/ms720165%28VS.85%29.aspx

I want to handle some SAPI messages from a DLL, which is some sort of plugin. How to handle messages/events inside a VC++ dll. The SAPI event handling is shown in the example at:
http://msdn.microsoft.com/en-us/library/ms720165%28VS.85%29.aspx

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

从此见与不见 2024-08-08 18:10:43

要处理“普通”消息,您仍然需要一个 Window 对象。 它可以是一个特殊的“仅消息”窗口,仅与普通窗口共享消息队列基础结构。 要创建它,首先使用 RegisterClass() 注册您的消息处理类。 接下来,通过将 HWND_MESSAGE 作为父窗口传递给 CreateWindow() 来创建消息队列。 您将得到一个 HWND,然后您可以返回到 SAPI。

然而,SAPI 也支持其他接口。 ISpNotifySource 文档名称 4:Windows 消息、回调、事件和 COM (ISpNotifySink)。 要使用回调,只需将 DLL 方法之一的地址传递给 SetNotifyCallbackFunction 即可。

To process "normal" messages, you still need a Window object. It can be a special "message-only" window that only shares the messaging queue infrastructure with normal windows. To create it, first register your message handling class with RegisterClass(). Next, create an message queue by passing HWND_MESSAGE as the parent window to CreateWindow(). You will get back an HWND you can then to SAPI.

However, SAPI supports other interfaces as well. The ISpNotifySource documentation names 4: Windows messages, callbacks, events and COM (ISpNotifySink). To use callbacks, simply pass the address of one of your DLL methods to SetNotifyCallbackFunction.

莫言歌 2024-08-08 18:10:43

如果您的代码作为插件运行,您可能需要考虑使用 ISpNotifySource::SetNotifyCallbackFunction 而不是 ISpNotifySource::SetNotifyWindowMessage。 当事件发生时,SAPI 将直接调用您的函数。

If your code is running as a plugin, you might want to look at having SAPI call you back directly using ISpNotifySource::SetNotifyCallbackFunction instead of ISpNotifySource::SetNotifyWindowMessage. SAPI will then call your function directly when an event occurs.

狼性发作 2024-08-08 18:10:43

WndProc 用于接收指向窗口的所有消息/事件。

您的 DLL 应该创建一个窗口并等待发送到该窗口的消息。 如果可能,您应该在主进程中实现这一点,或者您可以让 dll 创建一个单独的线程,该线程将创建窗口并等待消息,而实际函数将控制权返回给进程。

WndProc is used to recieve all messages/events directed at a window.

Your DLL should create a window and wait for messages to the window. If possible, you should implement this in your main process, or you can have the dll create a seperate thread that would create the window and wait for the message, while the actual function returns control to the process.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文