由于刚刚接触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] 

解决方案 »

  1.   

    你直接把那dqr或者pas文件Delphi编译生成一个不就成了
    如果报错XXX.dcu错误就把那个dcu删掉,估计因为是别人编译过的,所以会报错
      

  2.   

    楼主,你"一点都不懂DELPH",就来问这种问题,不太适合吧...
      

  3.   

    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.
      

  4.   

    unit Test;interfaceuses
      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.
      

  5.   

    http://download.csdn.net/source/862848
    其内有一个简易DEMO