找出阻止修改应用程序数据文件的过程 [英] Find out which process prevents to modify application data files

查看:48
本文介绍了找出阻止修改应用程序数据文件的过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时,某些进程使用了​​我的应用程序的某些文件.例如,用户打开应用程序日志或类似的日志,而忘记关闭它.这会在安装/升级/卸载时引起一些错误.在这种情况下,我想找出正在使用文件的进程,并向用户显示一条消息,指出已使用文件.

在Inno Setup中是否可以找出原因,什么过程阻止脚本修改文件?至少当我在代码"部分中尝试执行此操作时.

解决方案

Inno安装程序可以自动检查安装的文件是否被某些进程锁定,并为用户提供自动关闭(并稍后重新启动)应用程序的功能(因为5.5.0).

确保

Sometimes it happens, that some files of my application are used by some processes. For example, user opens application log, or something like that, and forgets to close it. This causes some errors while installing/upgrading/uninstalling. In such cases, I'd like to find out, what process is using file, and show user a message, indicating, that files are used.

Is it possible in Inno Setup to find out, what process prevents script from modifying file? At least, when I'm trying to do this in Code section.

解决方案

The Inno Setup can automatically check, if the installed files are locked by some processes, and offer a user to close (and restart later) the applications automatically (since 5.5.0).

Make sure the CloseApplications directive is set to its default value yes.

Though by default, only *.exe,*.dll,*.chm files are checked. If you want to check also other or all other files, modify the CloseApplicationsFilter directive:

[Setup]
; default
CloseApplications=yes
; check all files
CloseApplicationsFilter=*.*


If you are installing some files by a code, use the RegisterExtraCloseApplicationsResources event function:

procedure RegisterExtraCloseApplicationsResources;
begin
  RegisterExtraCloseApplicationsResource(
    False, ExpandConstant('{userappdata}\My Program.log')); 
end;


这篇关于找出阻止修改应用程序数据文件的过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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