我想用函数FindFirstChangeNotification实现监控 当文件夹里面有新的文件产生时就提示我去操作该文件, 我看了有C语言的例子不过没看过有delphi的例子 哪位大哥有delphi写的例子 提供一下 小弟谢谢了
解决方案 »
- Delphi2010 Barcode控件
- Delphi / C++Builder Beta 7.5 Build 16.0.4217.41600
- DELPHI 7 SQL server语句问题
- 在程序中往数据库添加记录????????????????
- 关于DELPHI7中TcpServer控件在某种条件下会停止监听的问题。
- 帮我看看哪儿有问题?
- 请问如何将一个包含多个动画文件的压缩包中的某一个动画文件释放出来并在内存空间运行。谢谢。
- 我想壮WIN2000,大家能不能谈经验
- 关于delphi与sql server连接的问题,谢谢!
- 请教,如何在多线程中使用ado访问数据库呢(空)
- 年纪大了,改行做仓库保管员了!!!散分!!!给CSDN认识和不认识的朋友们道声珍重!!!!
- 离职以我妥协告终。放分,憋却了好几天。顺便帮忙看看我该买哪个笔记本。
Windows, SysUtils, Classes, comctrls;type
TFileSysNotifyThread = class(TThread)
private
ErrCode: Integer;
KillAddress: PInteger;
NotifyHandle: THandle;
WatchPath: String;
WatchMask: Integer;
procedure SignalFileNotification;
protected
procedure Execute; override;
public
constructor Create (const AWatchPath: String; AWatchMask: Integer; var Myself: TFileSysNotifyThread);
destructor Destroy; override;
end;implementationuses Dialogs;constructor TFileSysNotifyThread.Create (const AWatchPath: String; AWatchMask: Integer; var Myself: TFileSysNotifyThread);
begin
Inherited Create (True);
WatchPath := AWatchPath;
WatchMask := AWatchMask;
KillAddress := Addr (Myself);
Priority := tpLower;
FreeOnTerminate := True;
Suspended := False;
end;destructor TFileSysNotifyThread.Destroy;
begin
if NotifyHandle <> THandle (-1) then
FindCloseChangeNotification (NotifyHandle);
Inherited Destroy;
KillAddress^ := 0;
end;procedure TFileSysNotifyThread.Execute;
begin
NotifyHandle := FindFirstChangeNotification (PChar (WatchPath), False, WatchMask);
if NotifyHandle <> THandle (-1) then while not Terminated do begin
ErrCode := WaitForSingleObject (NotifyHandle, 250);
case ErrCode of
Wait_Timeout:
;
Wait_Object_0:
begin
Synchronize (SignalFileNotification);
FindNextChangeNotification (NotifyHandle);
end;
else ;
end;
end;
end;procedure TFileSysNotifyThread.SignalFileNotification;
begin
ShowMessage ('文件已改变!');
end;end.