由于刚刚接触DELPH ,看了下DELPHI 下深入WINDOWS编程,要交选修课的论文。想做个监视目录里面的程序。但是不能编译运行。一点都不懂DELPH。
unit FileSysThread;interfaceuses
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.
往哪位高手帮忙改下,最好能生成一个.EXE文件。帮我传过来。[[email protected]][/email]
unit FileSysThread;interfaceuses
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.
往哪位高手帮忙改下,最好能生成一个.EXE文件。帮我传过来。[[email protected]][/email]
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货