你好,
我想在 MySQL 5.1.51 (XP SP3) 上的 MySQL UDF 中使用 Windows API Postmessage() 调用。我知道 UDF(用 Delphi 2006 编写)通过为 UDF 设置虚假结果来工作。
UDF 的语法采用两个整数参数,一个用于窗口句柄,另一个用于消息号。然而,从 UDF 内部调用 PostMessage() 会导致 mysqld 出现异常,并且服务停止。
有什么想法或指示吗?或者,如果有人可以告诉我如何通过 AnyDAC 和 Delphi 模拟 MySQL 的 IB 事件,或者当数据库中的记录发生更改时获取通知的替代方法,那么请告诉我。
——多诺万
G'Day,
I want to use the Windows API Postmessage() call from inside a MySQL UDF on MySQL 5.1.51 (XP SP3). I know the UDF (Written in Delphi 2006) is working by setting a bogus result for the UDF.
The syntax of the UDF takes two integer params, one for a window handle and the other for a message number. However a call to PostMessage() from inside my UDF causes an exception in mysqld and the service stops.
Any ideas or pointers? Alternatively if anyone can tell me how I am able to simulate IB Events for MySQL via AnyDAC and Delphi OR an alternate approach to getting a notification when a record has changed in the database then please show me the light.
--Donovan
发布评论
评论(3)
使用这种方法会遇到问题,主要是因为消息传递只能在相同的访问级别以及同一台计算机上的同一会话中起作用。使用其他方法会更好,例如 TCPIP 套接字、MailSlots、内存映射文件等。
为了最好地模拟发布消息,我将使用 TCPIP UDP。我过去使用过的一个很好的轻量级库是 Synapse。 SVN 的 synapse 库在最新版本的 Delphi 上运行得很好。为此,您要使用的类是 TUDPBlockSocket。
Your going to run into problems with this approach mainly due to the fact that messaging will only work to the same access level, and within the same session on the same computer. You would be better served by using other methods, such as TCPIP sockets, MailSlots, Memory mapped files, ect.
To best simulate a post message, I would use TCPIP UDP. A good lightweight library that I have used in the past is Synapse. The synapse library from SVN does run quite well against the latest versions of Delphi. The class you will want to use for this is the TUDPBlockSocket.
作为 Windows 消息或 TCP/IP 的替代方案,您可能需要考虑 命名管道 答案-send-a-string-from-one-instance-of-my-delphi-program-to-another">有关在两个 Delphi 程序之间发送信息的问题 和 这个关于什么是命名管道的问题。
——杰罗恩
As an alternative to windows messages or TCP/IP, you might want to consider the
named pipes
answer to this question on sending information between two Delphi programs and this question on what named pipes are.--jeroen
虽然我通过 UDF / Windows Pipe 路线取得了成功,但我还有另一个想法,可以利用 MySQL 中的信息消息框架(?)。请参阅https://stackoverflow.com/q/3992779/223742
While I have had success via the UDF / Windows Pipe route I had another idea leveraging off being able to tap into the information message framework(?) in MySQL. See https://stackoverflow.com/q/3992779/223742