ReadDirectoryChangesW 函数
ReadDirectoryChangesW 函數(shù)
對指定的目錄進行監(jiān)控,返回詳細的文件變化信息。
函數(shù)形式
01?BOOL?WINAPI?ReadDirectoryChangesW(
02?__in?????????HANDLE?hDirectory,???// 對目錄進行監(jiān)視的句柄
03?__out??????? LPVOID?lpBuffer,?????// 一個指向DWORD類型的緩沖區(qū),其中可以將獲取的數(shù)據(jù)結(jié)果將其返回。
04?__in???????? DWORD?nBufferLength,?// 指lpBuffer的緩沖區(qū)的大小值,以字節(jié)為單位。
05?__in???????? BOOL?bWatchSubtree,?// 監(jiān)視目錄. 一般選擇 TRUE
06?__in???????? DWORD?dwNotifyFilter,?// 對文件過濾的方式和標(biāo)準
07?__out_opt??? LPDWORD?lpBytesReturned,?// 將接收的字節(jié)數(shù)轉(zhuǎn)入lpBuffer參數(shù)
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.
?????? 被監(jiān)視的目錄必須打開FILE_LIST_DIRECTORY的訪問權(quán)限
???????
2.lpBuffer[中]
?????? The structure of this buffer is defined by the FILE_NOTIFY_INFORMATION structure
?????? 這個緩沖區(qū)的定義是FILE_NOTIFY_INFORMATION結(jié)構(gòu)。
?????? This buffer is filled either synchronously or asynchronously,?
?????? depending on how the directory is opened and what value is given to the lpOverlapped parameter.
?????? 這個緩沖區(qū)充滿要么同步或異步,這取決于如何打開目錄什么價值給予lpOverlapped參數(shù)。
3.nBufferLength [中]?
???????
?????? The size of the buffer that is pointed to by the lpBuffer parameter, in bytes.
?????? 大小的緩沖區(qū),是指出的lpBuffer參數(shù),以字節(jié)為單位。
4.bWatchSubtree [中]
?????? If this parameter is TRUE, the function monitors the directory tree rooted at the specified directory.
?????? 如果這個參數(shù)是TRUE,那么這個函數(shù)會監(jiān)視目錄樹,所指定的當(dāng)前的根目錄(整個路徑信息都顯示出來)。
?????? If this parameter is FALSE, the function monitors only the directory specified by the hDirectory parameter.
?????? 如果這個參數(shù)是FALSE ,則函數(shù)則只監(jiān)視hDirectory句柄所指定的目錄下的內(nèi)容(只顯示出發(fā)生變化的文件目錄)。?
???????
5.dwNotifyFilter [中]
?????? The filter criteria that the function checks to determine if the wait operation has completed.
?????? 該過濾器的標(biāo)準,功能檢查,以決定是否等待操作完成。?
?????? This parameter can be one or more of the following values.這個參數(shù)可以是一個或多個下列值。?
?????????
??????【FILE_NOTIFY_CHANGE_FILE_NAME】 0x00000001
?????? Any file name change in the watched directory or subtree causes a change notification wait operation to return.
?????? 任何文件名改變 都會查看所在目錄或子目錄的變更,并將結(jié)果通知給等待操作返回。?
?????? Changes include renaming, creating, or deleting a file.
?????? 變化包括重命名,創(chuàng)建或刪除文件。?
??????【FILE_NOTIFY_CHANGE_DIR_NAME】 0x00000002?
?????? Any directory-name change in the watched directory or subtree causes a change notification wait operation to return.
?????? 任何目錄名稱改變 都會查看所在目錄或子目錄的變更,并將結(jié)果通知給等待操作返回。
?????? 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.
?????? 任何屬性變化,都會查看所在目錄或子目錄的變更,并將結(jié)果通知給等待操作返回。
??????【FILE_NOTIFY_CHANGE_SIZE】 0x00000008?
?????? Any file-size change in the watched directory or subtree causes a change notification wait operation to return.
?????? 任何文件大小的變化,都會查看所在目錄或子目錄的變更,并將結(jié)果通知給等待操作返回。?
?????? The operating system detects a change in file size only when the file is written to the disk.
?????? 操作系統(tǒng)檢測改變文件大小,只有當(dāng)該文件被寫入到磁盤時發(fā)生。?
?????? For operating systems that use extensive caching, detection occurs only when the cache is sufficiently flushed.
?????? 操作系統(tǒng)使用廣泛緩存,檢測時才會發(fā)生的緩存足夠同滿。
??????【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.
?????? 任何改變過去修改時間的文件 ,都會查看所在目錄或子目錄的變更,并將結(jié)果通知給等待操作返回。
?????? The operating system detects a change to the last write-time only when the file is written to the disk.
?????? 操作系統(tǒng)檢測改變過去寫的時間只有當(dāng)該文件被寫入到磁盤。?
?????? For operating systems that use extensive caching, detection occurs only when the cache is sufficiently flushed.
?????? 操作系統(tǒng)使用廣泛緩存,檢測時才會發(fā)生的緩存足夠同滿。?
??????【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.
?????? 任何改變文件最近訪問時間,都會查看所在目錄或子目錄的變更,并將結(jié)果通知給等待操作返回。
??????【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.
?????? 任何改變文件的創(chuàng)建時間的,都會查看所在目錄或子目錄的變更,并將結(jié)果通知給等待操作返回。
??????【FILE_NOTIFY_CHANGE_SECURITY】0x00000100?
?????? Any security-descriptor change in the watched directory or subtree causes a change notification wait operation to return.
?????? 任何安全描述符被改變的,都會查看所在目錄或子目錄的變更,并將結(jié)果通知給等待操作返回。
6.lpBytesReturned [了,可選]?
?????? For synchronous calls, this parameter receives the number of bytes transferred into the lpBuffer parameter.
?????? 同步調(diào)用,這個參數(shù)接收的字節(jié)數(shù)轉(zhuǎn)入lpBuffer參數(shù)。?
?????? For asynchronous calls, this parameter is undefined.
?????? 異步調(diào)用,這個參數(shù)是未定義的。?
?????? You must use an asynchronous notification technique to retrieve the number of bytes transferred.
?????? 您必須使用異步通知技術(shù)檢索的字節(jié)數(shù)轉(zhuǎn)移。
7.lpOverlapped [中,那樣,可選]?
????????
?????? A pointer to an OVERLAPPED structure that supplies data to be used during asynchronous operation.
?????? 一個指針的重疊結(jié)構(gòu),提供供數(shù)據(jù)時使用的異步操作。?
???????
?????? Otherwise, this value is NULL.
?????? 否則,這個值為NULL 。?
???????
?????? The Offset and OffsetHigh members of this structure are not used.?
?????? OFFSET和OffsetHigh成員結(jié)構(gòu)不使用。
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.
?????? 一個指針一個完成例程 如果在呼叫使用函數(shù)操作時已經(jīng)完成或取消和調(diào)用線程是在alertable等待狀態(tài)。
???????
返回值
?????? If the function succeeds, the return value is nonzero.
?????? 如果函數(shù)成功,返回值為非零。
?????? For synchronous calls, this means that the operation succeeded.
?????? 同步要求,這意味著操作取得了成功。
?????? For asynchronous calls, this indicates that the operation was successfully queued.
?????? 異步調(diào)用,這表明操作成功排隊。
If the function fails, the return value is zero.
如果函數(shù)失敗,返回值是零。
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.
如果網(wǎng)絡(luò)重定向或目標(biāo)文件系統(tǒng)不支持這一行動,該功能失敗, ERROR_INVALID_FUNCTION 。
hat the operation succeeded.
?????? 同步要求,這意味著操作取得了成功。
?????? For asynchronous calls, this indicates that the operation was successfully queued.
?????? 異步調(diào)用,這表明操作成功排隊。
If the function fails, the return value is zero.
如果函數(shù)失敗,返回值是零。
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.
如果網(wǎng)絡(luò)重定向或目標(biāo)文件系統(tǒng)不支持這一行動,該功能失敗, ERROR_INVALID_FUNCTION 。
轉(zhuǎn)載于:https://www.cnblogs.com/darkdance/archive/2011/12/01/2270555.html
總結(jié)
以上是生活随笔為你收集整理的ReadDirectoryChangesW 函数的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 做梦梦到老婆出轨代表什么
- 下一篇: 【转】XP/2000无法使用“缩略图查看