Tutorial :Set environment variables from Delphi (Win32)


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.


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:



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.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »