BroadcastSystemMessage function (winuser.h)

Sends a message to the specified recipients. The recipients can be applications, installable drivers, network drivers, system-level device drivers, or any combination of these system components.

To receive additional information if the request is defined, use the BroadcastSystemMessageEx function.

Syntax

long BroadcastSystemMessage(
  [in]                DWORD   flags,
  [in, out, optional] LPDWORD lpInfo,
  [in]                UINT    Msg,
  [in]                WPARAM  wParam,
  [in]                LPARAM  lParam
);

Parameters

[in] flags

Type: DWORD

The broadcast option. This parameter can be one or more of the following values.

Value Meaning
BSF_ALLOWSFW
0x00000080
Enables the recipient to set the foreground window while processing the message.
BSF_FLUSHDISK
0x00000004
Flushes the disk after each recipient processes the message.
BSF_FORCEIFHUNG
0x00000020
Continues to broadcast the message, even if the time-out period elapses or one of the recipients is not responding.
BSF_IGNORECURRENTTASK
0x00000002
Does not send the message to windows that belong to the current task. This prevents an application from receiving its own message.
BSF_NOHANG
0x00000008
Forces a nonresponsive application to time out. If one of the recipients times out, do not continue broadcasting the message.
BSF_NOTIMEOUTIFNOTHUNG
0x00000040
Waits for a response to the message, as long as the recipient is not being unresponsive. Does not time out.
BSF_POSTMESSAGE
0x00000010
Posts the message. Do not use in combination with BSF_QUERY.
BSF_QUERY
0x00000001
Sends the message to one recipient at a time, sending to a subsequent recipient only if the current recipient returns TRUE.
BSF_SENDNOTIFYMESSAGE
0x00000100
Sends the message using SendNotifyMessage function. Do not use in combination with BSF_QUERY.

[in, out, optional] lpInfo

Type: LPDWORD

A pointer to a variable that contains and receives information about the recipients of the message.

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.

This parameter can be one or more of the following values.

Value Meaning
BSM_ALLCOMPONENTS
0x00000000
Broadcast to all system components.
BSM_ALLDESKTOPS
0x00000010
Broadcast to all desktops. Requires the SE_TCB_NAME privilege.
BSM_APPLICATIONS
0x00000008
Broadcast to applications.

[in] Msg

Type: UINT

The message to be sent.

For lists of the system-provided messages, see System-Defined Messages.

[in] wParam

Type: WPARAM

Additional message-specific information.

[in] lParam

Type: LPARAM

Additional message-specific information.

Return value

Type: long

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. To get extended error information, call GetLastError.

Remarks

If BSF_QUERY is not specified, the function sends the specified message to all requested recipients, ignoring values returned by those recipients.

The system only does marshalling for system messages (those in the range 0 to (WM_USER-1)). To send other messages (those >= WM_USER) to another process, you must do custom marshalling.

Examples

For an example, see Terminating a Process.

Requirements

Requirement Value
Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header winuser.h (include Windows.h)
Library User32.lib
DLL User32.dll

See also

BroadcastSystemMessageEx

Conceptual

Messages and Message Queues

Reference

SendNotifyMessage