转至繁体中文版     | 网站首页 | 图文教程 | 资源下载 | 站长博客 | 图片素材 | 武汉seo | 武汉网站优化 | 
最新公告:     敏韬网|教学资源学习资料永久免费分享站!  [mintao  2008年9月2日]        
您现在的位置: 学习笔记 >> 图文教程 >> 软件开发 >> Delphi程序 >> 正文
監視資源管理器的文件變化         ★★★★

監視資源管理器的文件變化

作者:闵涛 文章来源:闵涛的学习笔记 点击数:1956 更新时间:2009/4/23 18:25:46
else
      // 如果出现错误就使用 cotaskmemfree函数来释放句柄
      cotaskmemfree(m_pidldesktop);
    end;
    {$R+}
  end;
  
  function shnotify_unregister: bool;
  begin
    result := false;
    if boolean(m_hshnotify) then
    //取消系统消息监视,同时释放桌面的pidl
    if boolean(shchangenotifyderegister(m_hshnotify)) then begin
      {$R-}
      m_hshnotify := 0;
      cotaskmemfree(m_pidldesktop);
      result := true;
      {$R-}
    end;
  end;
  
  procedure tform1.wmshellreg(var message: tmessage); //系统消息处理函数
var
  strpath1, strpath2: string;
  charpath: array[0..259] of char;
  pidlitem: pshnotifystruct;
  vPath,vFile:string;
  begin
    pidlitem := pshnotifystruct(message.wparam);
    //  获得系统消息相关得路径
  shgetpathfromidlist(pidlitem.dwitem1, charpath);
    strpath1 := charpath;
    shgetpathfromidlist(pidlitem.dwitem2, charpath);
    strpath2 := charpath;
    vPath:=ExtractFilePath(strPath1);
    vFile:=ExtractFileName(strPath1);
    if (message.lparam=shcne_create) and (vPath=(Label1.Caption+''''\'''')) then
    begin
      // memo1.lines.add(sheventname(strpath1, strpath2, message.lparam) + chr(13) + chr(10));
    if not AnsiContainsText(Memo1.Lines.Text,vFile) then
      memo1.lines.add(vFile);
    end;
  end;
  
  
  procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
  begin
    //在程序退出的同时删除监视
  if boolean(m_pidldesktop) then
    shnotify_unregister;
    
  end;
  
  procedure TForm1.Button1Click(Sender: TObject);
  begin
    Memo1.Clear;
    m_hshnotify := 0;
    if shnotify_register(form1.handle) then begin //注册shell监视
    showmessage(''''shell监视程序成功注册'''');
      button1.enabled := false;
    end
    else
    showmessage(''''shell监视程序注册失败'''');
    
  end;
  
  procedure TForm1.Button2Click(Sender: TObject);
  var
  i:integer;
  begin
    i:=Memo1.Lines.IndexOf(Memo1.SelText);
    Memo1.Lines.Delete(i);
  end;
  
end.



上一页  [1] [2] 


没有相关教程
教程录入:mintao    责任编辑:mintao 
  • 上一篇教程:

  • 下一篇教程:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
      注:本站部分文章源于互联网,版权归原作者所有!如有侵权,请原作者与本站联系,本站将立即删除! 本站文章除特别注明外均可转载,但需注明出处! [MinTao学以致用网]
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)

    同类栏目
    · C语言系列  · VB.NET程序
    · JAVA开发  · Delphi程序
    · 脚本语言
    更多内容
    热门推荐 更多内容
  • 没有教程
  • 赞助链接
    更多内容
    闵涛博文 更多关于武汉SEO的内容
    500 - 内部服务器错误。

    500 - 内部服务器错误。

    您查找的资源存在问题,因而无法显示。

    | 设为首页 |加入收藏 | 联系站长 | 友情链接 | 版权申明 | 广告服务
    MinTao学以致用网

    Copyright @ 2007-2012 敏韬网(敏而好学,文韬武略--MinTao.Net)(学习笔记) Inc All Rights Reserved.
    闵涛 投放广告、内容合作请Q我! E_mail:admin@mintao.net(欢迎提供学习资源)

    站长:MinTao ICP备案号:鄂ICP备11006601号-18

    闵涛站盟:医药大全-武穴网A打造BCD……
    咸宁网络警察报警平台