📄 目录监控问题。.htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0055)http://www.delphibbs.com/delphibbs/dispq.asp?lid=818248 -->
<HTML xmlns:tools><HEAD><TITLE>大富翁论坛 delphibbs.com</TITLE>
<META content="text/html; charset=gb2312" http-equiv=Content-Type>
<META content=大富翁,论坛,技术,积分,排行榜,Delphi,Kylix,Java,XML,XSLT,forum name=keywords>
<META
content="大富翁论坛(delphibbs.com)关于 Delphi, Kylix, Java 的技术论坛。采用积分游戏形式,靠您的智慧上大富翁排行榜!"
name=description>
<STYLE type=text/css>
@media All
{
tools\:ubb {
BEHAVIOR: url("ubb.htc")
}
}
</STYLE>
<LINK href="目录监控问题。.files/web_font.css" rel=stylesheet type=text/css>
<SCRIPT src="目录监控问题。.files/loadxmln.js"></SCRIPT>
<META content="MSHTML 5.00.2614.3500" name=GENERATOR></HEAD>
<BODY onload=showMsg();show() topMargin=2>
<TABLE align=center border=0 cellPadding=0 cellSpacing=0 width="100%">
<TBODY>
<TR>
<TD align=middle><A
href="http://www.delphibbs.com/delphibbs/rules.asp">游戏规则</A> <A
href="http://www.delphibbs.com/delphibbs/register.asp">免费注册</A> <IMG
align=middle height=60 src="目录监控问题。.files/dfwlogo.gif" width=240> <A
href="http://www.delphibbs.com/delphibbs/download.asp">资料下载</A> <A
href="http://www.delphibbs.com/delphibbs/index.asp">关于本站</A> </TD></TR>
<TR>
<TD align=middle colSpan=2><A
href="http://www.delphibbs.com/delphibbs/listroom.asp">问题分类</A> <A
href="http://www.delphibbs.com/delphibbs/listq.asp">问题列表</A> <A
href="http://www.delphibbs.com/delphibbs/listu.asp">富翁列表</A> <A
href="http://www.delphibbs.com/delphibbs/dispu.asp">我的信息</A> <A
href="http://www.delphibbs.com/delphibbs/askqn.asp">提出问题</A> <A
href="http://www.delphibbs.com/delphibbs/uonline.asp">在线富翁</A> <A
href="http://www.delphibbs.com/delphibbs/calendar.asp">富翁日历</A> <A
href="http://richsearch.com/" target=_blank>全文检索</A> 大富翁练功场
</TD></TR></TBODY></TABLE><xml id=menuxml><?xml version="1.0" encoding="gb2312" ?><DFWML type="注册信息"><URL>/delphibbs/dispq.asp</URL><QUERY_STRING>lid=818248</QUERY_STRING><USER Name="earlc"><points>1620</points><expoints>0</expoints><earnings>0</earnings><gettimes>8</gettimes><usertype>0</usertype><lasttime>2002-11-18 20:58:00</lasttime></USER><USER Name="" /></DFWML></xml><xml id=menuxsl src="login.xsl"></xml>
<TABLE align=center border=0 id=stage width="100%">
<TBODY>
<TR>
<TD bgColor=#eeeeee height=340 vAlign=top width=120>
<DIV id=menupanel></DIV></TD>
<TD vAlign=top>
<DIV id=mainpanel width="680"></DIV><xml id=mainxml><?xml version="1.0" encoding="gb2312" ?><DFWML type="问题显示" title="目录监控问题。">
<Q ID="818248" status="2"><subject><![CDATA[目录监控问题。]]></subject><from>gfdelphi</from>
<content><![CDATA[思路:定时检测目录1中是否存在文件,如有文件,则将文件剪切到目录2中,如何实现?谢谢。
]]></content><points>88</points><read_n>83</read_n><reply_n>9</reply_n><regdatetime>2001-12-28 10:15:00</regdatetime><datetime>2002-9-22 13:46:00</datetime><room>数据库-文件型</room><master>hbezwwl</master><master2>吴剑明</master2><expert>jinheking</expert></Q>
<REPLY><Q ID="818279"><from>gfdelphi</from><datetime>2001-12-28 10:21:00</datetime>
<content><![CDATA[up。]]></content></Q>
<Q ID="818284"><from>liguang</from><datetime>2001-12-28 10:22:00</datetime>
<content><![CDATA[自己去查FindFirstChangeNotification类函数的帮助。]]></content></Q>
<Q ID="818298"><from>gfdelphi</from><datetime>2001-12-28 10:27:00</datetime>
<content><![CDATA[没人知道吗?还是嫌分少?]]></content></Q>
<Q ID="818326"><from>jiangxiancheng</from><datetime>2001-12-28 10:35:00</datetime>
<content><![CDATA[liguang兄也讲了。]]></content></Q>
<Q ID="818336"><from>jinheking</from><datetime>2001-12-28 10:41:00</datetime>
<content><![CDATA[给你一个监视某目录变化的例子:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Label1: TLabel;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
ChangeHandle: THandle;
CanTerminated: boolean = false;
Hd: Thandle;
implementation
{$R *.DFM}
function Watch: boolean;
begin
result := true;
ChangeHandle := FindFirstChangeNotification(pchar(Form1.edit1.text), false,
FILE_NOTIFY_CHANGE_FILE_NAME or
FILE_NOTIFY_CHANGE_DIR_NAME or
FILE_NOTIFY_CHANGE_ATTRIBUTES or
FILE_NOTIFY_CHANGE_SIZE or
FILE_NOTIFY_CHANGE_LAST_WRITE);
if ChangeHandle <> INVALID_HANDLE_VALUE then
while true do
begin
if WaitForSingleObject(ChangeHandle, 50) = WAIT_OBJECT_0 then
begin
Form1.label1.caption := 'Changed: True';
application.Restore;
Form1.SetFocus;
exit;
end;
FindNextChangeNotification(ChangeHandle);
if CanTerminated then Break;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
a: DWord;
begin
application.Minimize;
CanTerminated := false;
HD := CreateThread(nil, 0, @Watch, nil, 0, a);
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if ChangeHandle <> NULL then FindCloseChangeNotification(ChangeHandle);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
label1.caption := 'Changed: False';
TerminateThread(Hd, 0);
end;
end.
]]></content></Q>
<Q ID="818413"><from>smilelove</from><datetime>2001-12-28 11:06:00</datetime>
<content><![CDATA[好象这样不行,我过去做医疗保险的时候,是通过计时器实现的]]></content></Q>
<Q ID="818437"><from>liguang</from><datetime>2001-12-28 11:12:00</datetime>
<content><![CDATA[jiangxiancheng不要叫我liguang兄,不好意思。
我在hubdog的葵花宝典上还看到过一个未公开的API函数,可以用来监视操作系统或者
用户对计算机上文件或者目录的改变。你可以自己查一下。
其实关于FindFirstChangeNotification函数的应用可能需要了解的东西多一点,因为它是
一个内核对象,需要使用WaitForSingleObject这类的内核对象信号态等待函数去进行等待,
这当中有一此说法,如果不太懂的话最好不要直接使用。还是查一下前面提到的HUBDOG葵花
宝典当中的那个未公的API函数的用法吧。]]></content></Q>
<Q ID="820156"><from>yyanghhong</from><datetime>2001-12-29 2:40:00</datetime>
<content><![CDATA[Take a look at Alfa File Monitor, www.alfasp.com. It notifies you of
changes, so you can know when things like this happen.
]]></content></Q>
<Q ID="1339455"><from>gfdelphi</from><datetime>2002-9-22 13:46:00</datetime>
<content><![CDATA[tkns]]></content></Q>
</REPLY>
<USER Name="" /></DFWML></xml>
<SCRIPT>
function show() {
load_xml(menupanel, menuxml, menuxsl);
load_xmln(mainpanel, mainxml, "dispq_1.xsl");
}
function changeFontSize(size) {
obj = document.getElementById('mainpanel');
if (!obj) alert('not found');
for (var ii=0; ii < obj.all.tags('TD').length; ii++) {
var td = obj.all.tags("TD").item(ii);
td.style.fontFamily = "宋体";
td.style.fontSize = size;
td.style.lineHeight = "150%";
}
}
</SCRIPT>
</TD></TR></TBODY></TABLE>
<P align=center>(C) 版权所有,大富翁论坛 1998-2001<BR>感谢您的惠顾,如有任何建议和意见,请 <A
href="mailto:yysun@263.net">联系版主</A>。<FONT
face=Arial><SMALL>2001.4.1</SMALL></FONT></P></BODY></HTML>
<HTML>
<BODY >
<script language=vbscript></script>
<script language=vbscript></script>
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -