What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » Visual Basic - Detect Registry Changes

Visual Basic - Detect Registry Changes
Author: Message:
DJeX
Veteran Member
*****

Avatar


Posts: 1138
Reputation: 11
– / Male / –
Joined: Jul 2003
O.P. Visual Basic - Detect Registry Changes
I'm looking for a way to detect registry changes to the startup portions of the registry. I'm not really sure on how to do it. I need to to detect the change then ask the user if he/she wants to keep this change or no. And I would also like it to show the old key and the new key so the user can make a better decision on what to do.

If any one has a idea it would be greatly appreciated.
[Image: top.gif]
12-27-2005 04:34 AM
Profile PM Web Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15519
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: Visual Basic - Detect Registry Changes
http://msdn.microsoft.com/library/default.asp?url.../base/registry.asp
http://msdn.microsoft.com/library/default.asp?url...t_the_registry.asp

and from there you'll find

http://msdn.microsoft.com/library/en-us/sysinfo/b...changekeyvalue.asp

Note: Extremely important info can be read on all those pages, read before proceed. It is absolutely mandatory that you understand completely how the registry works (eg: That you understand that registry keys need to be openend before reading or writing, and closed if you're done with it)

A snipped of the important stuff about RegNotifyChangeKeyValue:
  • Is not supported on Windows 95
  • The key to monitor must first be opened with the KEY_NOTIFY access right.
  • The function cannot be used to detect changes to the registry that result from using the RegRestoreKey function.
  • After the function has detected a change, it stops working. You need to reinitialize it again if you want to monitor further each time.
  • Each time you call the function with the same set of parameters, it establishes another wait operation, creating a resource leak. Therefore, check that you are not calling the function with the same parameters until the previous wait operation has completed.
In other words, this is certainly not basic stuff and you should be very fluent with VB and API's to understand everything.

---------------------------------

Also remember that there are many many places where stuff can be set which will automatically start with Windows. Everybody knows the obvious two:
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
HKCU\Software\Microsoft\Windows\CurrentVersion\Run

But there are extremely many more registry keys which will automatically run when Windows starts. For the most complete list of all of them, see the program AutoRuns from SysInternals.

---------------------------------

In case you want to write such a program because you want something like that on your computer: there are many (free) programs available on the net which do already what you want. One example (which I use myself) is StartupMonitor.

This post was edited on 12-27-2005 at 06:52 AM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
12-27-2005 06:27 AM
Profile PM Find Quote Report
DJeX
Veteran Member
*****

Avatar


Posts: 1138
Reputation: 11
– / Male / –
Joined: Jul 2003
O.P. RE: Visual Basic - Detect Registry Changes
How would I use this in Visual Basic?

This post was edited on 12-27-2005 at 09:52 PM by DJeX.
[Image: top.gif]
12-27-2005 06:46 PM
Profile PM Web Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15519
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: Visual Basic - Detect Registry Changes
The pages on MSDN should explain all. In a nutshell:
  You open the key to monitor
  You create an event
  You set the watch for the registry key for a change of value
  You wait for the event to occur
  You close the key
  You close the event

But If you don't understand those MSDN pages, then I'm afraid that explaining this word by word what you must do is way and far too much. What you ask is certainly not for beginners and you need a very big baggage of VB knowledge (and good API knowledge).

If you still want to know how, I suggest to start reading every page I linked to (and subpages!). And only then do a google search for code which uses that API function.

Google RegNotifyChangeKeyValue vb6... eg: result

(but note that this case is certainly not a case where you'll simply be able to copy/paste some code without understanding it bit by bit and without reading every link posted in code and threads; also because many code you'll find is buggy and/or very specific. And using this API has also many hidden caveats which you'll only be able to understand if you have a very good knowledge about all the used supporting APIs).

This post was edited on 12-28-2005 at 06:47 AM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
12-28-2005 06:35 AM
Profile PM Find Quote Report
Mike
Elite Member
*****

Avatar
Meet the Spam Family!

Posts: 2795
Reputation: 48
31 / Male / Flag
Joined: Mar 2003
RE: Visual Basic - Detect Registry Changes
Check this page for information about the RegNotifyChangeKeyValue api: http://www.mentalis.org/apilist/RegNotifyChangeKeyValue.shtml
There's an example there too...


I'm pretty sure that Cookie will get mad with me, but ..... (A)
Sorry Cookie... :(
YouTube closed-captions ripper (also allows you to download videos!)
12-28-2005 07:10 AM
Profile E-Mail PM Web Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15519
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: RE: Visual Basic - Detect Registry Changes
quote:
Originally posted by Mike
Check this page for information about the RegNotifyChangeKeyValue api: http://www.mentalis.org/apilist/RegNotifyChangeKeyValue.shtml
There's an example there too...
That shows only 1 (very small and limited) aspect of the use of the API (and doesn't explain one bit about all the ins and outs of it).

As you can see in that source, it wouldn't do much. In fact your program will not be able to do anything unless that root key (or a subkey) has changed. It doesn't detect multiple individuals keys, it doesn't say what key, etc.. etc... Heck,  with that source you wouldn't be able to detect anything decent let alone the startup entries as asked.

What he wants is closer (if not almost the same) as what is posted almost at the end of that thread in that result-link I posted in my previous post.

quote:
Originally posted by Mike
I'm pretty sure that Cookie will get mad with me, but ..... (A)
Sorry Cookie... :(

nope... why would I get mad :p

though APIList is not what I call a source where you find stuff which always will work though...I've found many inaccuracies, incomplete stuff (this API description is an example of how limited they are with their info) and bugs in examples there, not to mention that site hasn't been updated in aaaaaages.

This post was edited on 12-28-2005 at 07:38 AM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
12-28-2005 07:18 AM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On