Monitor or hook a call to the Registry, and swap the returned value

  • Thread starter Thread starter ewolfman
  • Start date Start date
E

ewolfman

Hi,

Is there any way in which I can monitor / hook the Registry, and upon a
call to a specific key from a specific application - swap the returned
value?

I was thinking of using this method to overcome the "click" sound of
the WebBrowser, without having to affect the Registry permanently. This
way I could monitor the call for the sound file to be played (located
in
HKEY_CURRENT_USER\AppEvents\Schemes\Apps\Explorer\Navigating\.Current)
and hope to return an empty or null string instead.

Any idea on how to do this?

Thanks.
 
Just a thought.....

Wouldn't it be easier to use System.Diagnostics.Process to watch for the
application to start - change the value in the registry to a non-clicking
sound - then, when the app closes, change it back?

You'd probably want this solution running as a service.

Even easier (and no service needed) would be to write a tiny app that
changes the registry key, launches the webbrowser and replaces the registry
key when the browser closes.

Just a thought.....
 
Yeah, but thats the easy solution. Although it has its downsides too,
because it affects all navigation till the app closes, plus you can
never know if the app will not crash before it resets the Registry back
to its original value.

That's why I was looking for a different solution.
 
As you said, "you can never know if the app will not crash before it resets
the Registry back to its original value." This holds true for the easy
approach as well as hooking system events. In fact, it is even more of a
danger when hooking system events. If an app crashes while hooking system
events, this can cause the system to behave in unforeseen ways, even
crashing the system.

There are registry events that you can hook into using WMI or C++ at
http://windowssdk.msdn.microsoft.com/en-us/library/ms747845.aspx but it does
not work for the HKEY_CURRENT_USER hive and only monitors changes - not
reads.

And, although I know you don't like doing things the easy way, you could
always simply open the Windows Control Panel, then open sound properties
dialog and either choose silent sound scheme or just set no sound for start
navigation event.

Is there a reason for not setting this property permanently via the sound
properties control panel applet? After all, that sound sure is annoying.
 
I'm aware of the WMI capabilities, and this is why I asked the question
in the first place.

Its not that I don't like the easy way - of course I'd like to find an
easy way. The thing is that I don't think that switching the navigation
sound off, globaly, for the purpose of a single client application
instance, is the correct choice (unless I don't have any other choice,
and in this case I will ask the user for permission to do so).
 
There is one other option for your user... You can use AutoIT (freeware) to
give your user a simple icon to double click to turn the sound on or off.
You can get it at http://www.autoitscript.com/autoit3/. You can even make
compiled executable scripts that can be run without having to install AutoIT
on the users system.

Sorry I couldn't be of more help. Good luck to you.
 
Back
Top