Harry Ohlsen
11/6/2003 9:55:00 PM
Berger, Daniel wrote:
> I haven't looked at Win32::Registry, but this is from the MSDN site:
>
> To programmatically add or modify system environment variables, add them
> to the HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session
> Manager\Environment registry key, then broadcast a WM_SETTINGCHANGE
> message. This allows applications, such as the shell, to pick up your
> updates.
>
> So, perhaps there's some sort of "update" method that broadcasts the
> WM_SETTINGCHANGE. Otherwise, your option is OS.reboot. :)
Yes!
I eventually found some C++ code that did what SETX does. SETX is a command-line utility that comes with some kind of windows administration kit. It does basically what I was trying to do. By looking at the C++ source code I could see that it was broadcasting the WM_SETTINGCHANGE after updating the registry.
Since I'm definitely not much of a Windows programmer, it took me a while to find all the magic numbers, and work out the right types to specify for the parameters to Win32API::new, but I eventually got it working.
Fortunately, I have MSVC++ here at work, so I was able to search the header files to find the magic numbers.
Does anyone know whether there's a way to get those magic numbers (eg WM_SETTINGCHANGE) directly out of some DLL or something that comes standard with Windows? If not, maybe I'll write a script that runs through all the Windows C++ header files and generates a Ruby script that defines them all ... more likely a bunch of them, to allow pulling in only what a given script needs.
The other thing that would be really nice would be a way to generate the array of strings that Win32API::new takes to specify the parameter types for the system call. Does anyone have an idea how one might be able to do that?
Cheers,
Harry O.