Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "WinAPI";
Текущий архив: 2005.01.23;
Скачать: [xml.tar.bz2];

Вниз

Проблема с FILE_NOTIFY_INFORMATION   Найти похожие ветки 

 
MAINUSER ©   (2004-12-05 17:11) [0]

Уважаемые мастера, помогите мне понять, как объявляется FILE_NOTIFY_INFORMATION для ReadDirectoryChangesW.
В соответствующем исходнике используется переменная PFileNotifyInformation. В статье её не объявили, а сам я не знаю как её объявить. Помогите, кто знает. Спасибо


 
Morfein   (2004-12-05 19:01) [1]

кусок из хелпа по WinAPI
------------------------------------------------

The FIND_NOTIFY_INFORMATION structure describes the changes found by the ReadDirectoryChangesW function.

typedef struct _FILE_NOTIFY_INFORMATION {
  DWORD NextEntryOffset;
  DWORD Action;
  DWORD FileNameLength;
  WCHAR FileName[1];
} FILE_NOTIFY_INFORMATION;


Members

NextEntryOffset

Specifies the number of bytes that must be skipped to get to the next record. A value of zero indicates that this is the last record.

Action

Specifies the type of change that occurred.

Value Meaning
FILE_ACTION_ADDED The file was added to the directory.
FILE_ACTION_REMOVED The file was removed from the directory.
FILE_ACTION_MODIFIED The file was modified. This can be a change in the time stamp or attributes.
FILE_ACTION_RENAMED_OLD_NAME The file was renamed and this is the old name.
FILE_ACTION_RENAMED_NEW_NAME The file was renamed and this is the new name.


FileNameLength

Specifies the length, in bytes, of the filename portion of the record. Note that this length does not include the terminating null character.

FileName

This is a variable-length field that contains the filename relative to the directory handle. The filename is in the Unicode character format and is not null-terminated.



See Also: ReadDirectoryChangesW


 
Игорь Шевченко ©   (2004-12-05 20:36) [2]

type
 FILE_NOTIFY_INFORMATION = packed record
   NextEntryOffset: DWORD;
   Action: DWORD;
   FileNameLength: DWORD;
   FileName: WideChar;
 end;
 PFILE_NOTIFY_INFORMATION = ^FILE_NOTIFY_INFORMATION;


 
Игорь Шевченко ©   (2004-12-05 20:48) [3]

Точнее, так:

type
 FILE_NOTIFY_INFORMATION = packed record
   NextEntryOffset: DWORD;
   Action: DWORD;
   FileNameLength: DWORD;
   FileName: array[0..0] of WideChar;
 end;
 PFILE_NOTIFY_INFORMATION = ^FILE_NOTIFY_INFORMATION;


 
Игорь Шевченко ©   (2004-12-05 20:50) [4]

А таким образом можно получить список добавленных в каталог файлов из буфера ReadDirectoryChangesW:


procedure ParseNotificationBuffer (Buffer: PChar; AFiles: TStrings);
var
 PEntry: PFILE_NOTIFY_INFORMATION;
 MoreEntries: Boolean;
begin
 AFiles.Clear;
 PEntry := PFILE_NOTIFY_INFORMATION(Buffer);
 MoreEntries := true;
 while MoreEntries do begin
   if PEntry^.NextEntryOffset = 0 then
     MoreEntries := false;
   if PEntry^.Action = FILE_ACTION_ADDED then
     AFiles.Add(WideCharLenToString(PEntry^.FileName,
       PEntry^.FileNameLength div SizeOf(WideChar)));
   PEntry := PFILE_NOTIFY_INFORMATION(PChar(PEntry) + PEntry^.NextEntryOffset);
 end;
end;



Страницы: 1 вся ветка

Форум: "WinAPI";
Текущий архив: 2005.01.23;
Скачать: [xml.tar.bz2];

Наверх




Память: 0.45 MB
Время: 0.041 c
1-1105362698
Igor_thief
2005-01-10 16:11
2005.01.23
Скорость


3-1103629763
sesh
2004-12-21 14:49
2005.01.23
Excel --> Database


1-1104831765
studentas
2005-01-04 12:42
2005.01.23
Как вызвать ShowModal дочерней форме?


9-1097322125
Delphis
2004-10-09 15:42
2005.01.23
На весь экран


1-1105332216
Ray Eagle
2005-01-10 07:43
2005.01.23
интеграция отчета из Rave Reports





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский