建议它改为这样:(红色部分为修改)
TFileDealMethod = procedure(FileOperation: TFileOperation; const FileName1,
FileName2: string) of object;
改为:
TFileDealMethod = procedure(Sender: Tobject; FileOperation: TFileOperation; const FileName1,
FileName2: string) of object;
TCnFileSystemWatcher = class;//增加
TCnShellChangeThread = class(TThread)
private
FParent: TCnFileSystemWatcher;//增加
......
public
constructor Create(AParent:TCnFileSystemWatcher; ChangeEvent: TFileDealMethod); virtual;
.........
end;
constructor TCnShellChangeThread.Create(AParent:TCnFileSystemWatcher; ChangeEvent: TFileDealMethod);
begin
............
FParent := AParent;//增加
inherited Create(True);
end;
procedure TCnFileSystemWatcher.Start;
begin
if csDesigning in ComponentState then
Exit;
if Assigned(FOnChange) then
begin
FThread := TCnShellChangeThread.Create(Self,FOnChange);
..............
end;
procedure TCnShellChangeThread.DoIOCompletionEvent;
var
TempBuffer: TNotificationBuffer;
FileOpNotification: PFileNotifyInformation;
Offset: Longint;
FileName1, FileName2: string;
FileOperation: TFileOperation;
procedure DoDirChangeEvent;
var
IsInFileMasks: Boolean;
begin
if Assigned(ChangeEvent) and FActive then
begin
if FTmpFileMasks.Count > 0 then
IsInFileMasks := FileMatchesMasks(FileName1, FTmpFileMasks)
else
IsInFileMasks := FileMatchesMasks(FileName1, '*.*', False);
if IsInFileMasks then
begin
if FIncludePath then
begin
FileName1 := GetTrueFileName(FDirectory + FileName1);
if FileOperation = foRenamed then
FileName2 := GetTrueFileName(FDirectory + FileName2);
end;
ChangeEvent(FParent, FileOperation, FileName1, FileName2);
end;
end;
end;
function GetFileName(const FileName: PWideChar; FileNameLength: DWORD):string;
end;
[ 本帖最后由 小帆 于 2009-8-7 19:30 编辑 ]
|