1 /* $Id: cnotify.c,v 1.6 2003/06/07 16:16:39 chorns Exp $
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS system libraries
5 * FILE: lib/kernel32/file/find.c
6 * PURPOSE: Find functions
7 * PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
15 #include <kernel32/kernel32.h>
18 FindCloseChangeNotification (HANDLE hChangeHandle
)
20 NtClose(hChangeHandle
);
27 FindFirstChangeNotificationA (
29 WINBOOL bWatchSubtree
,
33 UNICODE_STRING PathNameU
;
37 RtlInitAnsiString (&PathName
,
40 /* convert ansi (or oem) string to unicode */
43 RtlAnsiStringToUnicodeString (&PathNameU
,
49 RtlOemStringToUnicodeString (&PathNameU
,
54 hNotify
= FindFirstChangeNotificationW (PathNameU
.Buffer
,
58 RtlFreeUnicodeString(&PathNameU
);
66 FindFirstChangeNotificationW (
68 WINBOOL bWatchSubtree
,
73 UNICODE_STRING NtPathU
;
74 IO_STATUS_BLOCK IoStatus
;
75 OBJECT_ATTRIBUTES ObjectAttributes
;
79 RtlDosPathNameToNtPathName takes a fully qualified file name "C:\Projects\LoadLibrary\Debug\TestDll.dll"
80 and returns something like "\??\C:\Projects\LoadLibrary\Debug\TestDll.dll."
81 If the file name cannot be interpreted, then the routine returns STATUS_OBJECT_PATH_SYNTAX_BAD and
85 if (!RtlDosPathNameToNtPathName_U ((LPWSTR
)lpPathName
,
90 SetLastErrorByStatus(STATUS_OBJECT_PATH_SYNTAX_BAD
);
91 return INVALID_HANDLE_VALUE
;
94 InitializeObjectAttributes (&ObjectAttributes
,
100 Status
= NtOpenFile (hDir
,
101 SYNCHRONIZE
|FILE_LIST_DIRECTORY
,
104 FILE_SHARE_READ
|FILE_SHARE_WRITE
|FILE_SHARE_DELETE
,
105 FILE_DIRECTORY_FILE
);
107 if (!NT_SUCCESS(Status
))
109 SetLastErrorByStatus(Status
);
110 return INVALID_HANDLE_VALUE
;
113 Status
= NtNotifyChangeDirectoryFile(hDir
,
122 if (!NT_SUCCESS(Status
))
124 SetLastErrorByStatus(Status
);
125 return INVALID_HANDLE_VALUE
;
134 FindNextChangeNotification (
138 IO_STATUS_BLOCK IoStatus
;
141 Status
= NtNotifyChangeDirectoryFile(hChangeHandle
,
148 FILE_NOTIFY_CHANGE_SECURITY
,//meaningless for subsequent calls, but must contain a valid flag(s)
149 0//meaningless for subsequent calls
151 if (!NT_SUCCESS(Status
))
153 SetLastErrorByStatus(Status
);