Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how to broadcast a WM_SETTINGCHANGE message

1,485 views
Skip to first unread message

Tom Esh

unread,
Feb 27, 2002, 8:37:18 PM2/27/02
to
WM_SETTINGCHANGE and WM_WININICHANGE are both defined as &H1. For some
reason, MS just decided to use two names and document them separately
rather than note the behavior / usage differences between NT3 and
Win9x / NT4+ in the same topic (go figure). Anyhow use the
WM_SETTINGCHANGE rules unless you're dealing with NT3. Also note that
you need to specify HWND_BROADCAST or HWND_TOPMOST (both defined as
-1&) as the hwnd if you want it sent to all top-level windows. Often
you can acheive the desired result with 0 in both wParam and lParam,
but it's better (and makes less work for the apps involved) if you're
as specific as possible.

On Wed, 27 Feb 2002 15:31:40 -0800, "sudheer sajja"
<sud...@mytechplace.com> wrote:
>I have a problem understanding the message arguments of
>the sendmessagetimeout function that is used to braodcast
>the WM_SETTINGCHANGE message to all the top level windows
>for shell updates.
>Its says wparam and lparam are specific to the
>WM_SETTINGCHANGE. Some places it shows WM_SETTINGCHANGE is
>similar to WM_WININICHANGE. I have &H1A as the constant
>value for WM_WININICHANGE, so when i use that it doesnt
>broadcast.
>could anybody help me with this issue

-Tom
(please post replies to the newsgroup)

sudheer sajja

unread,
Feb 28, 2002, 10:23:18 AM2/28/02
to
Tom,
i have set some system varaibles, but then i would have to
re-login to have the changes take effect. I was thinking
that by broadcasting the message i could automatically
refresh the values. does this happen by broadcasting the
message!!!!! I found values for WM_WININICHANGE as &h1A
and for HWND_BROADCAST as &hFFFF&. r they right.
sudheer sajja
>.
>

frank rizzo

unread,
Feb 28, 2002, 2:34:55 PM2/28/02
to
You shouldn't have to reboot unless:

1. The program in question is service-based, like IIS.
This happens because IIS has no windows which could
intercept the broadcast message. I've even tried stopping
& starting IIS, to no avail. I think the system caches
the environment variables for the services to use on
system startup or something like. If someone can show me
how to broadcast to services or apps without windows, that
would be great.

2. You are on Win9x.

Here is an example on how to broadcast:


Private Declare Function SendMessageTimeout Lib "user32" _
Alias "SendMessageTimeoutA" (ByVal hwnd As Long, _
ByVal msg As Long, ByVal wParam As Long, _
ByVal lParam As String, ByVal fuFlags As Long, _
ByVal uTimeout As Long, lpdwResult As Long) As Long

Private Const HWND_BROADCAST As Long = &HFFFF&
Private Const SMTO_ABORTIFHUNG As Long = &H2
Private Const WM_SETTINGCHANGE As Long = &H1A

Private Sub BroadcastEnvironmentChange()
Dim lngReturnValue As Long

SendMessageTimeout HWND_BROADCAST, _
WM_SETTINGCHANGE, 0&, _
"Environment", _
SMTO_ABORTIFHUNG, _
5000&, lngReturnValue
End Sub

>.
>

Tom Esh

unread,
Feb 28, 2002, 3:09:41 PM2/28/02
to
On Thu, 28 Feb 2002 07:23:18 -0800, "sudheer sajja"
<sud...@mytechplace.com> wrote:
>Tom,
>i have set some system varaibles, but then i would have to
>re-login to have the changes take effect. I was thinking
>that by broadcasting the message i could automatically
>refresh the values. does this happen by broadcasting the
>message!!!!! I found values for WM_WININICHANGE as &h1A
>and for HWND_BROADCAST as &hFFFF&. r they right.
>sudheer sajja
Oops. You're right, HWND_BROADCAST is &HFFFF or -1. (-1& would be
&HFFFFFFFF). Good catch.
Other than that, it may just be a matter of passing the correct args
for wParam and lParam.
Are the system variables anything you could be using
SystemParametersInfo for instead? If so it takes care of the params
for you, if you specify SPIF_SENDWININICHANGE flag.

_ m o r c i l l o @yahoo.com Eduardo A. Morcillo

unread,
Feb 28, 2002, 11:24:48 PM2/28/02
to
> 1. The program in question is service-based, like IIS.
> This happens because IIS has no windows which could
> intercept the broadcast message. I've even tried stopping
> & starting IIS, to no avail. I think the system caches
> the environment variables for the services to use on
> system startup or something like. If someone can show me
> how to broadcast to services or apps without windows, that
> would be great.

From the MSDN:

BroadcastSystemMessage
The BroadcastSystemMessage function 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.

--
Eduardo A. Morcillo (MS MVP)
http://www.domaindlx.com/e_morcillo


0 new messages