How to send notification messages with COM?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

How to send notification messages with COM?

Post by Ambush Commander »

I'm using the spiffy COM interface to read and write values from the registry:

Code: Select all

$shell = new COM('WScript.Shell');
$shell->RegWrite(
    $ureg_key . 'Path',  $user_path_string, 'REG_EXPAND_SZ'
);
For this particular case, I'm modifying the registry values that correspond to Window's environment variables. This lets me change my persistent environment variables without using setx or setenv.

Unfortunately, even though the registry is properly written to, it doesn't seem like Windows realizes that the environment has changed (not even when I reboot explorer). Apparently, I have to send a message to all the Windows in order to notify them of the change. I, unfortunately, have no idea how to do this with COM. Any ideas?

I'm currently working around this by executing an external setenv utility, but a built in PHP solution would be ideal.
Post Reply