0

我想处理来自 DLL 的一些 SAPI 消息,这是某种插件。如何处理 VC++ dll 中的消息/事件。SAPI 事件处理显示在示例中:http: //msdn.microsoft.com/en-us/library/ms720165%28VS.85%29.aspx

4

3 回答 3

5

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.

于 2009-08-17T08:46:39.590 回答
1

如果您的代码作为插件运行,您可能希望让 SAPI 直接使用ISpNotifySource::SetNotifyCallbackFunction而不是ISpNotifySource::SetNotifyWindowMessage回叫您。然后,SAPI 将在事件发生时直接调用您的函数。

于 2009-09-20T23:54:31.023 回答
0

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

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

于 2009-08-15T14:56:11.520 回答