How to know when and which files are changed in windows filesystem with winapi

谁都会走 提交于 2019-12-30 06:32:46

问题


I make program with spyware features for education, and I need to know in the program when file system is changing file, and what file is being changed.

How can I do that in C++?


回答1:


On Windows, look at SHChangeNotifyRegister(). Not only does it tell you what kind of change occured, but it also tells you which exact file(s) were changed.




回答2:


You are probably looking for Win32 Directory Change Notifications. There is also a .NET API called the FileSystemWatcher that exposes the same functionality.

The linked page gives a good example for subscribing to file system notifications. For more low-level access to filesystem changes you will have to look into Change Journals. That API is vastly more complicated so the first, directory change notifications, is probably your best place to start.

For the sake of mentioning it, the Linux kernel has a subsystem for this called inotifiy.



来源:https://stackoverflow.com/questions/13744138/how-to-know-when-and-which-files-are-changed-in-windows-filesystem-with-winapi

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!