rt,比如开打文件是什么消息,怎么拦截?
解决方案 »
- 只要你做了,就有分了,谢谢大家帮忙了
- 如何实现汉字排序?急!!!
- 以下程序怎么写,挺有挑战性的哟................300分
- 求助:实现一个excel功能的控件
- OBDC出错...不但变成英文版,而且驱动全不见
- sqlserver 一字段char(400) 在DELPHI编的程序只能看到200多个?
- NMSMTP发送邮件问题!如何设置用户名和密码
- 数据过滤的问题,大家快来帮帮我!
- 有谁能告诉我ESocketError(10053)错误是怎么产生的?(想看详细内容,请进...)
- 如何获取一个动态数组的列数及行数呀???
- 用ADOQuery连接数据库时提示“一般性网络错误”的问题,但ADOConnection已经连接?
- 提取主题词
呵呵
-------------------------------------
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;
可以实现相关信息返回
http://msdn.microsoft.com/