如何删除Windows正在使用的文件? [英] How to delete a file that is using by windows?

查看:102
本文介绍了如何删除Windows正在使用的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Windows中任何程序或其他进程使用文件时,是否可以删除文件?我搜索了
,发现了2种方法:

Is there any way to delete a file when its using by any program or other process in windows? I searched and found this 2 ways:

1-使用注册表中的RunOnce键;
我不会使用它,因为我不想等待Windows重新启动或其他任何事情...更喜欢按时完成!

1- using RunOnce key in Registry; I'm not gonna use this because i dont want to wait for windows restart or anything else... prefer to do it ontime!

2-使用在此页面中声明的方式: http://www.delphipages.com/forum/ showthread.php?t = 201190
这里的问题是在NT Windows下有用,我需要一种在所有Windows上都可以使用的方式!

2- using the way declared in this page: http://www.delphipages.com/forum/showthread.php?t=201190 the problem here is its useful under NT windows, i need a way works on all Windowses!

谢谢您。

推荐答案


这里的问题是在NT窗口下非常有用,我需要一种解决方法所有Windows !!

the problem here is its useful under NT windows, i need a way works on all Windowses!

所有现代台式机Windows(XP,Vista,7)也是NT。您真的需要使用NT< 4或Win98吗?甚至是Win CE / Mobile / Phone?可能不是。

All modern desktop Windowses (XP, Vista, 7) are also NT. Do you really need to work with NT<4 or Win98? Or even Win CE/Mobile/Phone? Probably not.

如果您需要立即删除一个打开的文件,唯一可以做的就是使用调试器特权将其附加到每个进程,看看它是否具有任何权限。处理文件上的打开,如果关闭,则将其关闭。您可以使用例如Process Explorer手动进行操作。许多应用程序对关闭其文件的反应不佳;

If you need to delete an open file straight away, about the only thing you can do is attach to each process using debugger privileges, see if it has any handles open on the file, and if so close them underneath it. You can do this the manual way using eg Process Explorer. Many applications won't react well to having their files closed on them; expect them to exception out when they try to do something with the dead handle.

不幸的是,Windows中没有选择将可以存在的Unix样式文件附加到文件中。文件句柄,而不是存储在光盘上的文件名下。

Unfortunately there is no option in Windows to have Unix-style files that can exist attached to a file handle independently of being stored under a filename on disc.

这篇关于如何删除Windows正在使用的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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