Delphi通知当一个文件被更新 [英] Delphi notification when a file gets updated

查看:285
本文介绍了Delphi通知当一个文件被更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序在其数据库中包含文档。用户可以在这种情况下打开文档,将文档保存到临时文件夹中,并在用户的计算机上打开。



我想收到通知这些临时文件之一被更改,并提供用户将更改的文档保存回数据库。



在Delphi7中最简单的方法是什么? (我想它需要一些shell魔术或第三方组件)



谢谢!

解决方案

您可以:


  1. 使用Win32 API SHChangeNotifyRegister 函数来监视temp文件夹中的更改,然后让你的回调检查你的临时文件是否报告更改。 / p>


  2. 由于您知道您感兴趣的确切文件,您可以使用 FindFirstFile 在计时器或线程中。



My app contains documents in its database. The users can open the documents in which case, the document gets saved to a temporary folder and gets opened on the user's computer.

I'd like to get a notification when one of these temporary files are changed, and offer the user to save the changed document back to the database.

What is the most simple way to do this in Delphi7? (I suppose it requires some shell magic or 3rd party component)

Thanks!

解决方案

You can either:

  1. use the Win32 API SHChangeNotifyRegister function to watch for changes in the temp folder, and then have your callback check if your temporary files are reporting changes.

  2. since you know the exact file(s) you are interested in, you can manually monitor them directly for changes to their sizes and timestamps using FindFirstFile in a timer or thread.

这篇关于Delphi通知当一个文件被更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆