rt,比如开打文件是什么消息,怎么拦截?

解决方案 »

  1.   

    乱贴一段代码
    呵呵
    -------------------------------------
    FindFirstChangeNotification
    FindNextChangeNotification
    可以监视某个目录下文件的变化!(打开,关闭,改名,写。。)具体的看API帮助!
    提供一个监视文件名的变化的例子:
    procedure TForm1.Button2Click(Sender: TObject);
    begin
      {establish a notification for file name changes on the selected directory}
      NotificationHandle := FindFirstChangeNotification(PChar(DirectoryListBox1.Directory), FALSE,FILE_NOTIFY_CHANGE_FILE_NAME);
      {if the notification was set up correctly, modify some UI elements...}
      if (NotificationHandle <> INVALID_HANDLE_VALUE) then
      begin
        Button1.Enabled := TRUE;
        Button2.Enabled := FALSE;
      end
      else
      begin
        {...otherwise indicate that there was an error}
        ShowMessage('There was an error setting the notification');
        Exit;
      end;
    end;procedure TForm1.Button1Click(Sender: TObject);
    var
      dwResult: DWORD;         // holds the result of waiting on the notification
      Waiting: Boolean;        // loop control variable
    begin
      {setup the loop control for a continuous loop}
      Waiting := TRUE;
      {indicate that the application is waiting for the change notification to fire}
      Button1.Enabled := FALSE;
      StatusBar1.SimpleText := 'Now waiting for a filename change';
      Application.ProcessMessages;
      {enter the loop}
      while Waiting do
      begin
        {at this point, the application is suspended until the notification
         object is signaled that a filename change has occured in the
         selected directory (this includes file deletions)}
        dwResult := WaitForSingleObject(NotificationHandle,INFINITE);
        if (dwResult = WAIT_OBJECT_0) then    begin
          {indicate that the notification object was signaled}
          ShowMessage('The selected directory signaled a filename change');      {query the user to see if they wish to continue monitoring this
           directory}
          if Application.MessageBox('Do you wish to continue monitoring this directory?', 'Continue?', MB_ICONQUESTION or
                                    MB_YESNO) = IDYES then        {if the user wishes to continue monitoring the directory, reset
             the notification object and continue the loop...}
            FindNextChangeNotification(NotificationHandle)
          else
            {...otherwise break out of the loop}
            Waiting := FALSE;
        end;
      end;  {close the notification object}
      FindCloseChangeNotification(NotificationHandle);  {reset UI elements}  Button1.Enabled := FALSE;
      Button2.Enabled := TRUE;
      StatusBar1.SimpleText := '';
      FileListBox1.Update;
    end;
      

  2.   

    SetWinDowsHookEx 中,当第一个参数为WH_SHELL 时
    可以实现相关信息返回
      

  3.   

    你难道连MSDN都没有?在线查
    http://msdn.microsoft.com/