ReadDirectoryChangesW 函数

ReadDirectoryChangesW 函数

ReadDirectoryChangesW 函数

对指定的目录进行监控,返回详细的文件变化信息。

函数形式

01 BOOL WINAPI ReadDirectoryChangesW(
02 
__in         HANDLE hDirectory,   // 对目录进行监视的句柄
03
 __out        LPVOID lpBuffer,     // 一个指向DWORD类型的缓冲区,其中可以将获取的数据结果将其返回。
04
 __in         DWORD nBufferLength, // 指lpBuffer的缓冲区的大小值,以字节为单位。
05 
__in         BOOL bWatchSubtree, // 监视目录. 一般选择 TRUE
06 
__in         DWORD dwNotifyFilter, // 对文件过滤的方式和标准
07 
__out_opt    LPDWORD lpBytesReturned, // 将接收的字节数转入lpBuffer参数
08 
__inout_opt LPOVERLAPPED lpOverlapped, // 一般选择 NULL
09 
__in_opt     LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine // 一般选择 NULL
10 );

1.hDirectory [中]

       This directory must be opened with the FILE_LIST_DIRECTORY access right.
       被监视的目录必须打开FILE_LIST_DIRECTORY的访问权限
       
2.lpBuffer[中]

       The structure of this buffer is defined by the FILE_NOTIFY_INFORMATION structure
       这个缓冲区的定义是FILE_NOTIFY_INFORMATION结构。
       This buffer is filled either synchronously or asynchronously, 
       depending on how the directory is opened and what value is given to the lpOverlapped parameter.
       这个缓冲区充满要么同步或异步,这取决于如何打开目录什么价值给予lpOverlapped参数。

3.nBufferLength [中] 
       
       The size of the buffer that is pointed to by the lpBuffer parameter, in bytes.
       大小的缓冲区,是指出的lpBuffer参数,以字节为单位。

4.bWatchSubtree [中]

       If this parameter is TRUE, the function monitors the directory tree rooted at the specified directory.
       如果这个参数是TRUE,那么这个函数会监视目录树,所指定的当前的根目录(整个路径信息都显示出来)。

       If this parameter is FALSE, the function monitors only the directory specified by the hDirectory parameter.
       如果这个参数是FALSE ,则函数则只监视hDirectory句柄所指定的目录下的内容(只显示出发生变化的文件目录)。 
       
5.dwNotifyFilter [中]

       The filter criteria that the function checks to determine if the wait operation has completed.
       该过滤器的标准,功能检查,以决定是否等待操作完成。 
       This parameter can be one or more of the following values.这个参数可以是一个或多个下列值。 
         
      【FILE_NOTIFY_CHANGE_FILE_NAME】 0x00000001
       Any file name change in the watched directory or subtree causes a change notification wait operation to return.
       任何文件名改变 都会查看所在目录或子目录的变更,并将结果通知给等待操作返回。 
       Changes include renaming, creating, or deleting a file.
       变化包括重命名,创建或删除文件。 

      【FILE_NOTIFY_CHANGE_DIR_NAME】 0x00000002 
       Any directory-name change in the watched directory or subtree causes a change notification wait operation to return.
       任何目录名称改变 都会查看所在目录或子目录的变更,并将结果通知给等待操作返回。
       Changes include creating or deleting a directory.
       改变包括建立或删除一个目录。 

      【FILE_NOTIFY_CHANGE_ATTRIBUTES】 0x00000004 
       Any attribute change in the watched directory or subtree causes a change notification wait operation to return.
       任何属性变化,都会查看所在目录或子目录的变更,并将结果通知给等待操作返回。

      【FILE_NOTIFY_CHANGE_SIZE】 0x00000008 
       Any file-size change in the watched directory or subtree causes a change notification wait operation to return.
       任何文件大小的变化,都会查看所在目录或子目录的变更,并将结果通知给等待操作返回。 
       The operating system detects a change in file size only when the file is written to the disk.
       操作系统检测改变文件大小,只有当该文件被写入到磁盘时发生。 
       For operating systems that use extensive caching, detection occurs only when the cache is sufficiently flushed.
       操作系统使用广泛缓存,检测时才会发生的缓存足够同满。

      【FILE_NOTIFY_CHANGE_LAST_WRITE】0x00000010 
       Any change to the last write-time of files in the watched directory or subtree causes a change notification wait operation to return.
       任何改变过去修改时间的文件 ,都会查看所在目录或子目录的变更,并将结果通知给等待操作返回。
       The operating system detects a change to the last write-time only when the file is written to the disk.
       操作系统检测改变过去写的时间只有当该文件被写入到磁盘。 
       For operating systems that use extensive caching, detection occurs only when the cache is sufficiently flushed.
       操作系统使用广泛缓存,检测时才会发生的缓存足够同满。 

      【FILE_NOTIFY_CHANGE_LAST_ACCESS】0x00000020 
       Any change to the last access time of files in the watched directory or subtree causes a change notification wait operation to return.
       任何改变文件最近访问时间,都会查看所在目录或子目录的变更,并将结果通知给等待操作返回。

      【FILE_NOTIFY_CHANGE_CREATION】 0x00000040 
       Any change to the creation time of files in the watched directory or subtree causes a change notification wait operation to return.
       任何改变文件的创建时间的,都会查看所在目录或子目录的变更,并将结果通知给等待操作返回。

      【FILE_NOTIFY_CHANGE_SECURITY】0x00000100 
       Any security-descriptor change in the watched directory or subtree causes a change notification wait operation to return.
       任何安全描述符被改变的,都会查看所在目录或子目录的变更,并将结果通知给等待操作返回。

6.lpBytesReturned [了,可选] 

       For synchronous calls, this parameter receives the number of bytes transferred into the lpBuffer parameter.
       同步调用,这个参数接收的字节数转入lpBuffer参数。 
       For asynchronous calls, this parameter is undefined.
       异步调用,这个参数是未定义的。 
       You must use an asynchronous notification technique to retrieve the number of bytes transferred.
       您必须使用异步通知技术检索的字节数转移。

7.lpOverlapped [中,那样,可选] 
        
       A pointer to an OVERLAPPED structure that supplies data to be used during asynchronous operation.
       一个指针的重叠结构,提供供数据时使用的异步操作。 
       
       Otherwise, this value is NULL.
       否则,这个值为NULL 。 
       
       The Offset and OffsetHigh members of this structure are not used. 
       OFFSET和OffsetHigh成员结构不使用。

8.lpCompletionRoutine [中,可选] 

 

       A pointer to a completion routine to be called when the operation has been completed or canceled and the calling 
       thread is in an alertable wait state.
       一个指针一个完成例程 如果在呼叫使用函数操作时已经完成或取消和调用线程是在alertable等待状态。
       
返回值

       If the function succeeds, the return value is nonzero.
       如果函数成功,返回值为非零。

       For synchronous calls, this means that the operation succeeded.
       同步要求,这意味着操作取得了成功。

       For asynchronous calls, this indicates that the operation was successfully queued.
       异步调用,这表明操作成功排队。

If the function fails, the return value is zero.
如果函数失败,返回值是零。

To get extended error information, call GetLastError .
要获得扩展错误信息,请用GetLastError返回错误 。

If the network redirector or the target file system does not support this operation, the function fails with ERROR_INVALID_FUNCTION.
如果网络重定向或目标文件系统不支持这一行动,该功能失败, ERROR_INVALID_FUNCTION 。

hat the operation succeeded.
       同步要求,这意味着操作取得了成功。

       For asynchronous calls, this indicates that the operation was successfully queued.
       异步调用,这表明操作成功排队。

If the function fails, the return value is zero.
如果函数失败,返回值是零。

To get extended error information, call GetLastError .
要获得扩展错误信息,请用GetLastError返回错误 。

If the network redirector or the target file system does not support this operation, the function fails with ERROR_INVALID_FUNCTION.
如果网络重定向或目标文件系统不支持这一行动,该功能失败, ERROR_INVALID_FUNCTION 。

posted on 2011-12-01 14:36 流沙- 阅读(...) 评论(...) 编辑 收藏

转载于:https://www.cnblogs.com/darkdance/archive/2011/12/01/2270555.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/404637.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

flask web开发的相关博文学习

一、基础教程 flask-tutorial/SUMMARY.md at master greyli/flask-tutorial GitHubThe Flask Mega-Tutorial Part I: Hello, World! - miguelgrinberg.com全面的Flask教程 - 简书Flask入门教程 - HelloFlask 主推miguelgrinberg,课程如下 二、高级应用 flask-sq…

[react] 请说说什么是useRef?

[react] 请说说什么是useRef? 本质上 createRef 和 useRef(mountRef) 就是创建一个 {current: initialState} 对象然后返回 useRef 本身经历两个阶段:mountRef 和 updateRef,updateRef 就是把 memoziedState&#xff…

【Visual C++】游戏开发笔记十九 DirectX与OpenGL的博弈

From: http://blog.csdn.net/zhmxy555/article/details/7522960 本系列文章由zhmxy555(毛星云)编写,转载请注明出处。 http://blog.csdn.net/zhmxy555/article/details/7522960 作者:毛星云 邮箱: happylifemxyqq.…

写在前面-2015.11.30

本人90后,工作不是很久,大学期间主修软件工程,也在课外班学习java开发,后机缘巧合学习测试。截止2015年末,功测1年经验,(纯手工)自动化没有实战经验仅限于了解。目前性能测试一年。主…

linux c 获取时间戳 打印时间戳

以下是项目开发中常用到的时间戳接口,可以直接用。 一、相关接口 二、代码实现 char* lgw_get_now_time(void) {time_t timep;time(&timep);return asctime(localtime(&timep)); } int lgw_get_now_tick(void) {time_t timep;time(&timep);return ti…

[react] react的性能优化在哪个生命周期?它优化的原理是什么?

[react] react的性能优化在哪个生命周期?它优化的原理是什么? shouldComponentUpdate 减少不必要的重新渲染 个人简介 我是歌谣,欢迎和大家一起交流前后端知识。放弃很容易, 但坚持一定很酷。欢迎大家一起讨论 主目录 与歌谣…

让source insight更好的支持中文

From: http://blog.csdn.net/aylixuan/article/details/6066126 1.记事本录入以下文字: /* * 代替SourceInsight原有的Backspace功能(希望如此) * 增加了对双字节汉字的支持,在删除汉字的时候也能同时删除汉字的高字节而缓解…

阿里云linux主机安装qt报错:缺少libxkbcommon-x11.so.0

ubuntu云主机安装xfce桌面后,下载qt5.12.10,开发桌面应用,安装qt时报错缺少libxkbcommon-x11.so.0。 由于xfce是轻量级桌面不带libxkbcommon-x11.so.0,而qt5.12.10默认系统已经自带,所以,报错。此时更新一下…

[react] 你知道的react性能优化有哪些方法?

[react] 你知道的react性能优化有哪些方法? shouldComponentUpdate PureComponent :Class ComponentReact.Memo :Function ComponentuseCallback :Memoized FunctionuseMemo :Memozied Value个人简介 我是歌谣&#…

【转】XP/2000无法使用“缩略图查看”、右键无“设置桌面背景”选项问题详解...

许多朋友在XP或2000系统下查看图片时,经常碰到以下几个问题: 1. 当我查看文件夹里面的图片,以缩略图方式查看时,却发现系统不能显示图片内容了,只是出来一个简单的图片图标(就和我们以图标或平铺显示的…

PHP的curl实现get,post 和 cookie(几个实例)

类似于dreamhost这类主机服务商,是显示fopen 的使用 的。使用php的curl可以实现支持FTP、FTPS、HTTP HTPPS SCP SFTP TFTP TELNET DICT FILE和LDAP。curl 支持SSL证书、HTTP POST、HTTP PUT 、FTP 上传,kerberos、基于HTT格式的上传、代理、cookie、用户…

Qt treeWidget 查找指定字段内容的条目并跳转到该条目

遍历Qt treeWidget,查找指定字段内容的条目,并跳转到该条目。 void MainWindow::on_pushButton_sidFind_clicked() {QString sid ui->lineEdit_sidFind->text();QTreeWidgetItemIterator it(ui->treeWidget_sqItem);while (*it) {if ((*it)-&…

[react] 什么是浅层渲染?

[react] 什么是浅层渲染? 当为 React 写单元测试时,浅层渲染(Shallow Renderer) 会变得十分有用。浅层渲染使你可以渲染 “单层深度” 的组件,并且对组件的 render 方法的返回值进行断言,不用担心子组件的行为,组件并…

document.all和document.layers

document.all是IE 4.0及以上版本的专有属性,是一个表示当前文档的所有对象的娄组,不仅包括页面上可见的实体对象,还包括一些不可见的对象,比如html注释等等。在document.all数组里面,元素不分层次,是按照其…

strip and linux lib compile

From: http://www.360doc.com/content/11/0808/17/7472348_138951246.shtml strip经常用来去除目标文件中的一些符号表、调试符号表信息,以减小程序的大小,在rpmbuild包的最后就用到。 其支持的选项如下: >strip -h 用法:str…

SpringMVC之控制器的单例和多例管理

版权声明:本文为博主原创文章,未经博主允许不得转载。 在使用Spring3对控制器Controller进行bean管理时,如果要对控制器是否单例进行管理。 有两种方式配置多例模式: 1.springXML 2.注解本身的控制器类 [java] view plaincopyprin…

Python多个版本指定如何指定

1、指定python3 32bit 版本安装SciPy库 py -3-32 -m pip install SciPy 2、指定python2 64bit 版本安装SciPy库 py -2-64 -m pip install SciPy 3、进入指定版本根目录执行操作 D:\Tools\python37_32bit>python.exe -m pip list

[react] react16的reconciliation和commit分别是什么?

[react] react16的reconciliation和commit分别是什么? React 16 三个核心: Scheduler 调度器:决定什么时候调度 ReconcilerReconciler 协调器:进行 Fiber diff 及新的 Fiber 树的生成以及副作用记录Commit 将新的树应用到 DOM 中…

BZOJ 1997: [Hnoi2010]Planar( 2sat )

平面图中E ≤ V*2-6..一个圈上2个点的边可以是在外或者内, 经典的2sat问题..------------------------------------------------------------------------------------------#include<cstdio>#include<cstring>#include<algorithm>#include<stack>usin…