本文介绍了是否有人在C ++ / WinAPI中有类似FileSystemWatcher的类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个.Net的FileSystemWatcher模拟原始C ++ / WinAPI。
我几乎开始使用FindFirstChangeNotification / FindNextChangeNotification自己编码一个,但是我发现我可能不是第一个需要这个的人,也许有人愿意分享。

I need a .Net's FileSystemWatcher analog in raw C++/WinAPI.I almost started to code one myself using FindFirstChangeNotification/FindNextChangeNotification, but then it occurred to me that I am probably not the first one who needs this and maybe someone will be willing to share.

理想情况下,我需要的是一个类,可以使用如下:

Ideally what I need is a class which can be used as follows:

FileWatcher fw;
fw.startWatching("C:\MYDIR", "filename.dat", 
     FileWatcher::SIZE | FileWatcher::LAST_WRITE,
     &myChangeHandler);
...
fw.stopWatching();

或者如果它会使用像boost :: signal这样会更好。
但是,除了标准库之外,没有依赖项,boost和raw WinAPI。
谢谢!

Or if it would use somehting like boost::signal it would be even better.But please, no dependencies other than the Standard Library, boost and raw WinAPI.Thanks!

推荐答案

ReadDirectoryChangesW函数呢?

What about the ReadDirectoryChangesW function?

它会将通知存储在缓冲区中,以便不会漏掉任何更改(除非缓冲区溢出)

It stores notifications in a buffer so you don't miss any changes (unless the buffer overflows)

这篇关于是否有人在C ++ / WinAPI中有类似FileSystemWatcher的类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 18:40