2010년 7월 8일 목요일

지정폴더 변화 감시 함수

자신이 원하는 폴더에서의 변화를 감지하고 싶을때가 있을 것이다.

이러한 변화 감지를 위해서 WIN32 API 는 FindFirstChangeNotification 과 FindNextChangeNotification 함수를 제공한다.

다음은 MSDN에 정의되어 있는 내용이다.

HANDLE WINAPI FindFirstChangeNotification(

__in LPCTSTR lpPathName,

__in BOOL bWatchSubtree,

__in DWORD dwNotifyFilter

);

LpPathName 은 경로, bWatchSubtree 는 하위폴더까지 감시할 것인지를 dwNotifyFilter 는 변화알림에 대한 상태필터이다.

dwNotifyFilter 에 들어갈 값들에 대한 정의이다.

Value

Meaning

FILE_NOTIFY_CHANGE_FILE_NAME

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 name.

FILE_NOTIFY_CHANGE_DIR_NAME

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

Any attribute change in the watched directory or subtree causes a change notification wait operation to return.

FILE_NOTIFY_CHANGE_SIZE

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

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_SECURITY

Any security-descriptor change in the watched directory or subtree causes a change notification wait operation to return.

댓글 없음:

댓글 쓰기