views:

581

answers:

2

I'm trying to set a system wide environment variable from within my delphi application. The Documentation says to add a registry key to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment and then broadcast a WM_SETTINGCHANGE message. Anyone know how to Broadcast this message?

PS. I'm trying to do this in a console application.

+5  A: 

Call SendMessage. Use HWnd_Broadcast as the target window.

A better option may be SendNotifyMessage, which doesn't wait for all the recipients to return.

Rob Kennedy
+1  A: 

There is also a topic in the Embarcadero Developer Network covering this issue and providing sample code for sending the message. The author uses SendMessageTimeout as recommended in the MSDN doc for WM_SETTINGCHANGE:

http://edn.embarcadero.com/article/28254

Heinrich Ulbricht