------------ Дoбавленo в 14.04:
MSDN-FILE_NOTIFY_INFORMATION писал(а):
FileName
A variable-length field that contains the file name relative to the directory handle. The file name is in the Unicode character format and is not null-terminated.
Получилось примерно так:
#pas
procedure THiDirectoryChanges.HandleEvent;
var FileNotifyInfo : PFileNotifyInformation;
InfoCallBack : TInfoCallBack;
Offset : Longint;
WStr: string;
begin
Pointer(FileNotifyInfo) := @FWatchBuf[0];
repeat
Offset:=FileNotifyInfo^.NextEntryOffset;
InfoCallBack.FAction := FileNotifyInfo^.Action;
InfoCallBack.FDrive := FName;
SetLength(WStr, FileNotifyInfo.FileNameLength+1); // На 1 больше, так как должна оканчиваться двумя #0
WStr[FileNotifyInfo.FileNameLength + 1] := #0; // В конце получается #0#0
Move(FileNotifyInfo^.FileName[0], WStr[1], FileNotifyInfo.FileNameLength);
WStr := Trim(WideCharLenToString(@WStr[1], FileNotifyInfo.FileNameLength));
InfoCallBack.FNewFileName := WStr;
case FileNotifyInfo^.Action of
FILE_ACTION_RENAMED_OLD_NAME: FOldFileName := WStr;
FILE_ACTION_RENAMED_NEW_NAME: InfoCallBack.FOldFileName := FOldFileName;
end;
FInfoCallBack(InfoCallBack, sTag);
PChar(FileNotifyInfo) := PChar(FileNotifyInfo) + Offset;
until (Offset=0) or WFS.Terminated or (WFS = nil);
end;