怎样发送广播消息,在多个应用程序之间

King_Dragon 2002-05-28 01:47:04
我在看有关消息方面的书籍时,看到可以利用SendMessage或者PostMessage在多个应用程序之间发送广播消息,具体还要用到RegisterWindowMessage函数来注册新的消息,谁有例程或是源代码之类,能提供源代码最好,要是能够讲清楚原理也可以。
我的疑惑:怎样注册并发送广播消息?接收到广播消息的程序中怎样获得发送方的窗口Handle,怎样处理?
...全文
165 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
King_Dragon 2002-05-28
  • 打赏
  • 举报
回复
不好意思,看错了,是只有Win NT提供此项功能,嘻嘻!
King_Dragon 2002-05-28
  • 打赏
  • 举报
回复
mrzho(mrzhou) 你还漏了点东西,就是Win NT上不支持这个函数,我用的Win2K.
King_Dragon 2002-05-28
  • 打赏
  • 举报
回复
老大,不知道又没有关系,何必摘抄帮助呢,这东西我的机器上有,你要中文的话我可以帮你翻译!
哎,给点实质性的东西,这些纸上谈兵的东西我也知道!算了,大家都是为了赚分,呵呵!
mrzho 2002-05-28
  • 打赏
  • 举报
回复
The BroadcastSystemMessage function sends a message to the specified recipients. The recipients can be applications, installable drivers, Windows-based network drivers, system-level device drivers, or any combination of these system components.

long BroadcastSystemMessage(

DWORD dwFlags,
LPDWORD lpdwRecipients,
UINT uiMessage,
WPARAM wParam,
LPARAM lParam
);


Parameters

dwFlags

Option flags. Can be a combination of the following values:

Value Meaning
BSF_FLUSHDISK Flush the disk after each recipient processes the message.
BSF_FORCEIFHUNG Continue to broadcast the message, even if the time-out period elapses or one of the recipients is hung..
BSF_IGNORECURRENTTASK Do not send the message to windows that belong to the current task. This prevents an application from receiving its own message.
BSF_NOHANG Force a hung application to time out. If one of the recipients times out, do not continue broadcasting the message.
BSF_NOTIMEOUTIFNOTHUNG Wait for a response to the message, as long as the recipient is not hung. Do not time out.
BSF_POSTMESSAGE Post the message. Do not use in combination with BSF_QUERY.
BSF_QUERY Send the message to one recipient at a time, sending to a subsequent recipient only if the current recipient returns TRUE.


lpdwRecipients

Pointer to a variable that contains and receives information about the recipients of the message. The variable can be a combination of the following values:

Value Meaning
BSM_ALLCOMPONENTS Broadcast to all system components.
BSM_ALLDESKTOPS Windows NT only: Broadcast to all desktops. Requires the SE_TCB_NAME privilege.
BSM_APPLICATIONS Broadcast to applications.
BSM_INSTALLABLEDRIVERS Windows 95: Broadcast to installable drivers.Windows NT: This value is not meaningful.
BSM_NETDRIVER Windows 95: Broadcast to Windows-based network drivers.Windows NT: This value is not meaningful.
BSM_VXDS Windows 95: Broadcast to all system-level device drivers.Windows NT: This value is not meaningful.


When the function returns, this variable receives a combination of these values identifying which recipients actually received the message.
If this parameter is NULL, the function broadcasts to all components.

uiMessage

Identifier of the system message.

wParam

32-bit message-specific value.

lParam

32-bit message-specific value.



Return Values

If the function succeeds, the return value is a positive value.
If the function is unable to broadcast the message, the return value is -1.
If the dwFlags parameter is BSF_QUERY and at least one recipient returned BROADCAST_QUERY_DENY to the corresponding message, the return value is zero.

Remarks

If BSF_QUERY is not specified, the function sends the specified message to all requested recipients, ignoring values returned by those recipients.
haishen 2002-05-28
  • 打赏
  • 举报
回复
关注
S_caijing 2002-05-28
  • 打赏
  • 举报
回复
这在帮助中有

5,392

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧