由于刚刚接触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]
解决方案 »
- 有什么语句可以得到interbase数据库中是否存在某表
- 如何从几张表中取出满足条件的条目显示到DBGrid中
- idtcpclient的困惑!
- 用Delphi和MapX开发GIS系统问题,如何实现在mapx1地图窗口中多个车辆动态显示,并当同一辆车发生位置变化时,车辆随之变化,最好能在地图上显示车辆行驶轨迹?
- 数据表保存不定时出错!
- 这样来调用一个OBJ文件呢---------------------
- 关于怎么样连接一个Access数据库?
- 高分请教:怎样在win2000/Nt下取得主板序列号?
- idtcpserver与java socket通信中文乱码!!!
- 请问要开发自己的数据库,需要哪些方面的知识(Fairton/飞云)
- 有人用delphi写过条码打印吗? 打印机是godex ez1100
- pagecontrol中关闭创建的tabsheet问题
如果报错XXX.dcu错误就把那个dcu删掉,估计因为是别人编译过的,所以会报错
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.
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ComCtrls, ExtCtrls, FileSysThread;type
TForm1 = class(TForm)
Button1: TButton;
Button3: TButton;
Edit1: TEdit;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
MyThread1 : TFileSysNotifyThread;
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.DFM}procedure TForm1.Button1Click (Sender: TObject);
begin
if MyThread1 = Nil then
MyThread1 := TFileSysNotifyThread.Create (edit1.text, File_Notify_Change_File_Name or File_Notify_Change_Dir_Name, MyThread1)
else ShowMessage ('线程正在运行');
end;procedure TForm1.Button3Click (Sender: TObject);
begin
if MyThread1 <> nil then
MyThread1.Terminate
else ShowMessage ('线程未运行');
end;procedure TForm1.FormCreate(Sender: TObject);
beginend;procedure TForm1.FormDestroy (Sender: TObject);
begin
if MyThread1 <> Nil then
begin
MyThread1.Terminate;
MyThread1.WaitFor;
end;
end;end.
其内有一个简易DEMO