-
文件修改监控
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
-
A very nice Flash+ XML image carousel source
很漂亮的Flash+XML图片轮播源码, -A very nice Flash+ XML image carousel source
- 2022-07-19 06:50:36下载
- 积分:1
-
简单的联系list.vcproj
Simple Linked List.vcproj
- 2022-01-26 08:03:21下载
- 积分:1
-
Cpphtml is a utility to convert your C++ code to HTML. If you have a C++ file, s
Cpphtml is a utility to convert your C++ code to HTML. If you have a C++ file, say myprogram.cpp, and you want to put it on your website, you can run it through Cpphtml which will convert the code to HTML with all comments, keywords and preprocessor directives highlighted. Cpphtml will send all output to cout, so you have to redirect the output to a file if you want to create a HTML file
- 2022-12-14 19:50:03下载
- 积分:1
-
对于bacnetip虚拟链路层文件
Document for BACnetIP Virtual Link Layer
- 2022-06-20 03:42:08下载
- 积分:1
-
操作系统课程设计,用VC开发可直接下载使用,包含消息机制,共享内存和管道通信...
操作系统课程设计,用VC开发可直接下载使用,包含消息机制,共享内存和管道通信-Operating system, curriculum design, developed with the VC can directly download that contains message mechanism, shared memory, and communication channels
- 2022-01-26 01:03:11下载
- 积分:1
-
这是一个用来输出对称的菱形星号的程序,分别输出实心和空心的菱形星号...
这是一个用来输出对称的菱形星号的程序,分别输出实心和空心的菱形星号-This is a symmetry of the diamond used to output an asterisk procedures, respectively, the output of solid and hollow diamond asterisk
- 2022-03-05 01:36:23下载
- 积分:1
-
网络结构图控件中的数据类型定义,可用于配置分布式系统网络结构...
网络结构图控件中的数据类型定义,可用于配置分布式系统网络结构-network control structure of the data type definition, can be used to configure distributed network structure
- 2022-06-01 06:03:20下载
- 积分:1
-
友善之臂2410开发版上写的一个串口打印程序
友善之臂2410开发版上写的一个串口打印程序-Development of arm-friendly version of 2410 to write a serial printing process
- 2022-01-24 16:38:11下载
- 积分:1
-
DOS下的fc文件比较工具,自动输出文件差异。
DOS下的fc文件比较工具,自动输出文件差异。-fc under the DOS file comparison tools, automatic output files difference.
- 2022-04-30 12:07:54下载
- 积分:1