文件更新时的 Delphi 通知 [英] Delphi notification when a file gets updated

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

问题描述

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

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.

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

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

谢谢!

推荐答案

您可以:

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

  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.

因为您知道自己感兴趣的确切文件,所以您可以使用 FindFirstFile 在计时器或线程中.

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天全站免登陆