CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Jun 2001
    Location
    Denmark
    Posts
    453

    Question Detecting changes to file system and/or registry

    I need to detect changes to (certain) files whenever they are accessed, a bit similar to what a virus scanner does with on-access scan.

    Also, I need to get notified whenever a change of any kind is made in the registry.

    Rather than taking snapshots of the file(s) or registry and then compare them to what I had earlier, I was hoping to be able to get some sort of event that I could subscribe to. Is that possible?

  2. #2
    Join Date
    Sep 2004
    Location
    Holland (land of the dope)
    Posts
    4,123

    Re: Detecting changes to file system and/or registry

    I need to detect changes to (certain) files whenever they are accessed
    ReadDirectoryChanges

  3. #3
    Join Date
    Jun 2001
    Location
    Denmark
    Posts
    453

    Re: Detecting changes to file system and/or registry

    A good start, I suppose, but I'd hoped for something that would send an event to me when it happened. I suppose that I will have to poll the directory I watch (which by choosing C:\ I suppose will give me all changes on that drive for instance). Hm...but it did say something about an asynchronous operation...I wonder if I could call it and order it to return whenever something happened. Then I would sort of have an event sent to me...

  4. #4
    Join Date
    Sep 2004
    Location
    Holland (land of the dope)
    Posts
    4,123

    Re: Detecting changes to file system and/or registry

    A good start, I suppose, but I'd hoped for something that would send an event to me when it happened.
    It does. Use the async implementation. The callback function will be triggered if something happened. Google a bit for 'filewatcher c++'... there are a lot of ready to use classes out there.

  5. #5
    Join Date
    Jun 2001
    Location
    Denmark
    Posts
    453

    Re: Detecting changes to file system and/or registry

    Cool, thanks.

    I hope there's something similar for the registry...

  6. #6
    Join Date
    Apr 1999
    Posts
    3,585

    Re: Detecting changes to file system and/or registry

    RegNotifyChangeKeyValue should provide registry notification.
    Gort...Klaatu, Barada Nikto!

  7. #7
    Join Date
    Jun 2001
    Location
    Denmark
    Posts
    453

    Re: Detecting changes to file system and/or registry

    It seems we're on the right track here. :-)

    However, while RegNotifyChangeKeyValue() will tell that something has changed, it seems that in order to get to know *what* was changed, one needs either Vista or Server 2008. Since there are still lots of XP clients out there, I hope there is also something to get details of the change that will support XP.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured