我用D6写了一个类,创建一个线程来监视一个目录,在主窗体中按一个Button调用,D6下无任何问题,完全正常。
但到了D5下,类无问题,只是Button的代码里,最后一个End出错,就是下面打了括号的地方:Button1.Click
begin
  ......
  begin
    .....
  end
  .....
(end)出错信息如下:Project WDASClient.exe raised exception class EAbstractError with message 'Abstract Error'.Process stopped........好象是关于抽象方法什么的请问该如何解决啊?我现在只能在D5下调试编译,所以必须解决这个问题~~请大虾们救命啊!!!!

解决方案 »

  1.   

    不知,把你Button所在的窗体代码全部贴出来看看。
      

  2.   

    procedure TfmMainClient.btnBeginWatchClick(Sender: TObject);    //开始监视的按钮点击后
    begin
      if WatchDirThread = nil then
      begin
        try
          StatusBar1.Panels[0].Text := '正在创建监视线程...';
          WatchDirThread := TWatchDirThread.Create(edtLocalDir.Text,
                                                  FILE_NOTIFY_CHANGE_FILE_NAME
                                               or FILE_NOTIFY_CHANGE_DIR_NAME
                                               or FILE_NOTIFY_CHANGE_SIZE,
                                                  WatchDirThread);
          btnBeginWatch.Enabled := False;
          btnEndWatch.Enabled := True;
          StatusBar1.Panels[0].Text := '正在监视 ' + edtLocalDir.Text;
        except
          Application.MessageBox('创建监视线程失败','监视',0+16);
        end;
      end;
    end;procedure TfmMainClient.FormDestroy(Sender: TObject);   //销毁线程
    begin
      if WatchDirThread <> nil then
      begin
        StatusBar1.Panels[0].Text := '正在终止监视线程...';
        WatchDirThread.Terminate;
        StatusBar1.Panels[0].Text := '监视停止';
      end;
    end;;
      

  3.   

    接上面:
    type
      //监视线程类
      TWatchDirThread = class(TThread)
      private
        FErrCode : Integer;
        FKillAddress : PInteger;
        FNotifyHandle : THandle;
        FWatchDir : String;
        FWatchMask : Integer;
        FDirFile : TDirFileList;
        procedure SignalDirNotification;
      protected
        procedure Execute;override;
      public
        constructor Create(const AWatchDir : String;AWatchMask : Integer;var WatchThread : TWatchDirThread);virtual;
        destructor Destroy;override;    property WatchDir : String read FWatchDir;
      end;implementationuses MainClient;{ TWatchDirThread }constructor TWatchDirThread.Create(const AWatchDir: String;
      AWatchMask: Integer; var WatchThread: TWatchDirThread);
    begin
      Inherited Create(True);
      FWatchDir := AWatchDir;
      FWatchMask := AWatchMask;
      FKillAddress := Addr(WatchThread);
      Priority := tpLower;
      FreeOnTerminate := True;
      Suspended := False;
      FDirFile := TDirFileList.Create;
    end;destructor TWatchDirThread.Destroy;
    begin
      if FNotifyHandle <> THandle(-1) then
        FindCloseChangeNotification(FNotifyHandle);
      inherited;
      FKillAddress^ := 0;
    end;procedure TWatchDirThread.Execute;
    begin
      inherited;
      FNotifyHandle := FindFirstChangeNotification(PChar(FWatchDir),False,FWatchMask);
      if FNotifyHandle <> THandle(-1) then
      begin
        while not Terminated do
        begin
          FErrCode := WaitForSingleObject(FNotifyHandle,250);
          case FErrCode of
            Wait_TimeOut :
              ;
            Wait_Object_0 : begin
                              Synchronize(SignalDirNotification);
                              FindNextChangeNotification(FNotifyHandle);
                            end;
          end;
        end;
      end;
    end;procedure TWatchDirThread.SignalDirNotification;
    var
      ChangeFile : TStrings;
      i : Integer;
    begin
      ChangeFile := TStringList.Create;
      if FDirFile.GetChangedFile(FWatchDir,True,ChangeFile) then
      begin
        for i := 0 to ChangeFile.Count-1 do
          fmMainClient.mmInfo.Lines.Add(ChangeFile.Strings[i]);
      end;
    end;end.
      

  4.   

    忘了说了,错误就在Button点击时间里procedure TfmMainClient.btnBeginWatchClick(Sender: TObject);    //开始监视的按钮点击后
    begin
      if WatchDirThread = nil then
      begin
        try
          StatusBar1.Panels[0].Text := '正在创建监视线程...';
          WatchDirThread := TWatchDirThread.Create(edtLocalDir.Text,
                                                  FILE_NOTIFY_CHANGE_FILE_NAME
                                               or FILE_NOTIFY_CHANGE_DIR_NAME
                                               or FILE_NOTIFY_CHANGE_SIZE,
                                                  WatchDirThread);
          btnBeginWatch.Enabled := False;
          btnEndWatch.Enabled := True;
          StatusBar1.Panels[0].Text := '正在监视 ' + edtLocalDir.Text;
        except
          Application.MessageBox('创建监视线程失败','监视',0+16);
        end;
      end;
    end;    //////这一句错