-
文件修改监控
ReadDirectoryChangesW 有同步和异步2种方式,
根据前面打开的文件夹对象句柄决定。
1. 异步方式,如果 CreateFile 指定了打开类型 FILE_FLAG_OVERLAPPED 就是异步方式,ReadDirectoryChangesW 调用的时候就需要指定 OVERLAPPED 参数.
接下来对文件夹I/O变化的响应判断有多种方式。
A通过不断的调用HasOverlappedIoCompleted函数(非阻塞,参数就是前面的OVERLAPPED 对象指针)的返回值来判断是否发生了 关注文件句柄的I/O操作。如果发生变化,再执行你的 switch(Buffer[0].Action) 操作过程。
B GetOverlappedResult 读取 OVERLAPPED 对象的结果。(阻塞)
C 完成端口 GetQueuedCompletionStatus (阻塞)。
其中阻塞方式,必须采用多线程的方式,否则你的主线程被阻塞的话,对话框就动不了了。非阻塞方式也可用多线程,结合hEvent对象来使用。
2.同步方式,如果CreateFile不指定FILE_FLAG_OVERLAPPED ,就是同步方式。
同步方式操作比较简单。lz的程序看来就是使用的同步方式。
在同步下,ReadDirectoryChangesW 将被阻塞,直到一个文件夹句柄的I/O操作到来,然后才能判断。所以lz的程序会死掉。
同步方式必须采用多线程,再创建一个线程,线程函数采用如下方式:
UINT ThreadProc(PVOID)
{
CreateFile();
while(1) // 如果只想监视一次文件的I/O变化,可不用while循环。
{
- 2022-03-10 05:44:52下载
- 积分:1
-
吉林大学车辆工程考研资料,欢迎大家下载。欢迎大家提出意见。...
吉林大学车辆工程考研资料,欢迎大家下载。欢迎大家提出意见。-Jilin University vehicle engineering study section of the information, welcome you to download. Welcome to submit their views.
- 2023-05-26 20:35:04下载
- 积分:1
-
wedd hello world
this is a hello world log hahathis is a hello world log hahathis is a hello world log hahathis is a hello world log hahathis is a hello world log hahathis is a hello world log hahathis is a hello world log hahathis is a hello world log hahathis is a hello world log hahathis is a hello world log hahathis is a hello world log haha
- 2022-07-04 14:54:06下载
- 积分:1
-
Socket编程示例
Socket编程示例-Socket Programming Example
- 2022-02-07 11:50:21下载
- 积分:1
-
键盘输入按键,然后输入到苔藓按钮开关码
键盘输入按键,然后导入Moss按键开关代码
- 2022-10-03 04:05:03下载
- 积分:1
-
visual basic程序实现反平行四边形机构设计
visual basic程序实现反平行四边形机构设计-visual basic program to achieve the anti-parallelogram mechanism design
- 2022-10-04 15:55:04下载
- 积分:1
-
一些很好的播发器的
一些很好的播发器的-some of the good of the transmitters
- 2022-11-21 09:45:03下载
- 积分:1
-
这是一个用EXCEL表格内容是关于一些统计,调查等
这是一个用EXCEL表格内容是关于一些统计,调查等-Excel is about some statistics, surveys, etc.
- 2022-02-21 22:43:59下载
- 积分:1
-
Windows程序设计第五版示例源码
《Windows程序设计第五版》配套光盘源码,VS都可编译通过。
- 2022-02-25 11:48:42下载
- 积分:1
-
用了好久的AVR编程软件,不错,跟大家分享一下!
用了好久的AVR编程软件,不错,跟大家分享一下!-Used for a long time of AVR programming software, yes, to share with you!
- 2022-12-30 17:45:04下载
- 积分:1