ReadDirectoryChangesW-程序员宅基地

技术标签: c++  QT  

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 。

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/savagelin/article/details/125895872

智能推荐

Linux中的交叉编译_linux 交叉编译-程序员宅基地

一直以为要编译出不同编译环境下能运行的程序需要安装相同的编译版本,然后试着去用源码安装gcc版本,看了教程太烦还出现了教程里没有的错误,很烦很气。可是突然看到交叉编译这个概念交叉编译 编辑简单地说,就是在一个平台上生成另一个平台上的可执行代码。同一个体系结构可以运行不同的操作系统;同样,同一个操作系统也可以在不同的体系结构上运行。一直以为交叉编译是用来在Windows上编译linux程序用的,其实..._linux 交叉编译

jquery 插件开发 $.extend $.fn.extend 全局对象 全局函数-程序员宅基地

Query插件的开发包括两种:一种是类级别的插件开发,即给jQuery添加新的全局函数,相当于给jQuery类本身添加方法。jQuery的全局函数就是属于jQuery命名空间的函数,另一种是对象级别的插件开发,即给jQuery对象添加方法。下面就两种函数的开发做详细的说明。1、类级别的插件开发类级别的插件开发最直接的理解就是给jQuery类添

PDF页面参差不齐统一页面大小--Adobe印刷制作功能-程序员宅基地

在PDF格式转换的过程中遇到各种问题,比如转换出现乱码、转出来的文件是图片无法编辑、转换时提示文件权限不足等等,今天我就来和大家介绍用扫描的图片制作pdf文档页面大小不一致常用三种解决方法,希望可以帮助到大家。  通过视图>工具>印刷制作实现  1、运行AdobeAcrobatXpro,打开需要处理的pdf文件,可以看到各页面宽窄不一;  2、在转换界面左上角依

STL顺序容器(C++ Primer记)_c++ primer dict 容器-程序员宅基地

STL顺序容器概览1.容器定义和初始化//For example vector<int>a;//空 vector<int>b(a); //b是a的拷贝 vector<int>c = b; //与上一行等价 vector<int>d{ 1,2,3,4_c++ primer dict 容器

4.23学习笔记-程序员宅基地

学习内容:java基础:听一场讲座:pandas基础:python实践:padas实践:人工智能:人工智能属于计算机,python比较火,目前的想法利用java写交互,然后调用python的接口实现人工智能算法的研究。因此要从头开始学习。弱人工智能:机器人,语音识别,游戏,面部识别强人工智能:类似人类大脑超人工智能:超过人类的大脑人工智能:分为:模式识别,机器学习,数据...

GRE词汇精选——分享与睡眠-程序员宅基地

lethargy n.昏睡,倦怠  nap n.v.小睡,打盹  repose v.躺着休息,安睡  slumber v.n.睡眠,安睡  slumberous adj.昏昏欲睡的  dormant adj.冬眠的,静止的  hibernate v.冬眠,蛰伏  hibernation n.冬眠  hypnosis n.催眠状态  hypnotic adj.催眠

随便推点

makefile增量编译(生成依赖关系)_makefile 增量编译-程序员宅基地

1Makefile基本用法1.1常用符号1.1.1编译器CC // C语言编译器,默认值为gcc默认的变量,无需用户自定义,也可以改变其值CXX // C++语言编译器,默认值为g++默认的变量,无需用户自定义,也可以改变其值CFLAGS // C语言编译器的编译选项LDFLAGS // C语言编译器的链接选项CX..._makefile 增量编译

前端实现实时消息提醒消息通知_前端网页关闭后收到消息进行提示-程序员宅基地

前端实现消息提醒_前端网页关闭后收到消息进行提示

SpringCloudAlibaba——Sentinel持久化规则_springcloud sentinel 持久化 使用详解-程序员宅基地

Sentinel持久化规则哪样的情况进行持久化设置?一旦我们重启应用,sentinel规则将消失,生产环境需要将配置规则进行持久化。持久化的思路:将限流配置规则持久化进Nacos保存,只要刷新8401某个rest地址,sentinel控制台的流控规则就能看到,只要Nacos里面的配置不删除,针对8401上sentinel上的流控规则持续有效。设置持久化规则的流程:添加依赖: ..._springcloud sentinel 持久化 使用详解

jdk1.7 新特性-程序员宅基地

1,switch中可以使用字串了String s = "test"; switch (s) { case "test" : System.out.println("test"); case "test1" : System.out.println("test1"); break ; default : System.out.println("break");

重新打包流中的异常-程序员宅基地

Java 8已有两年的历史了,但是仍然存在社区尚未为其开发好的解决方案的用例,甚至边缘用例。 如何处理流管道中的已检查异常就是这样的问题之一。 Stream操作接受的功能接口不允许实现抛出已检查的异常,但是我们可能要调用许多方法。 显然,这里存在一种紧张关系,许多开发人员都曾遇到过这种紧张关系。 我想在简短的系列文章中探讨这个主题: 重新打包流中的异常 重新打包异常以便抛出它们..._编译打包时 方法内抛throw错