FindFirstChangeNotification function
Applies to: desktop apps only
Creates a change notification handle and sets up initial change notification filter conditions. A wait on a notification handle succeeds when a change matching the filter conditions occurs in the specified directory or subtree. The function does not report changes to the specified directory itself.
This function does not indicate the change that satisfied the wait condition. To retrieve information about the specific change as part of the notification, use the ReadDirectoryChangesW function.
Syntax
HANDLE WINAPI FindFirstChangeNotification( __in LPCTSTR lpPathName, __in BOOL bWatchSubtree, __in DWORD dwNotifyFilter );
Parameters
- lpPathName [in]
-
The full path of the directory to be watched. This cannot be a relative path or an empty string.
In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. For more information, see Naming a File.
- bWatchSubtree [in]
-
If this parameter is TRUE, the function monitors the directory tree rooted at the specified directory; if it is FALSE, it monitors only the specified directory.
- dwNotifyFilter [in]
-
The filter conditions that satisfy a change notification wait. This parameter can be one or more of the following values.
Return value
If the function succeeds, the return value is a handle to a find change notification object.
If the function fails, the return value is INVALID_HANDLE_VALUE. To get extended error information, call GetLastError.
Remarks
The wait functions can monitor the specified directory or subtree by using the handle returned by the FindFirstChangeNotification function. A wait is satisfied when one of the filter conditions occurs in the monitored directory or subtree.
After the wait has been satisfied, the application can respond to this condition and continue monitoring the directory by calling the FindNextChangeNotification function and the appropriate wait function. When the handle is no longer needed, it can be closed by using the FindCloseChangeNotification function.
Notifications may not be returned when calling FindFirstChangeNotification for a remote file system.
Symbolic link behavior—If the path points to a symbolic link, the notification handle is created for the target.
If an application has registered to receive change notifications for a directory that contains symbolic links, the application is only notified when the symbolic links have been changed, not the target files.
Examples
For an example, see Obtaining Directory Change_Notifications.
Requirements
|
Minimum supported client | Windows XP |
|---|---|
|
Minimum supported server | Windows Server 2003 |
|
Header |
|
|
Library |
|
|
DLL |
|
|
Unicode and ANSI names | FindFirstChangeNotificationW (Unicode) and FindFirstChangeNotificationA (ANSI) |
See also
- Directory Management Functions
- FindCloseChangeNotification
- FindNextChangeNotification
- ReadDirectoryChangesW
Send comments about this topic to Microsoft
Build date: 4/17/2012
- 9/7/2011
- NCJr
- 8/15/2011
- AlonaR
HANDLE h = FindFirstChangeNotification( NULL, false, FILE_NOTIFY_CHANGE_LAST_WRITE );
if ( h != INVALID_HANDLE_VALUE )
{
printf( "Value of handle is 0x%x\n", h );
// WFSO return WAIT_FAILED & GetLastError returns the invalid handle code
DWORD test = WaitForSingleObject( h, 1 );
}
This is consistent on XP and Vista x86.
- 4/23/2008
- David Lowndes
- 4/23/2008
- David Lowndes