如何检查资源管理器上是否打开了文件夹? [英] How to check if a folder opened on explorer?

查看:155
本文介绍了如何检查资源管理器上是否打开了文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要检查我的文件夹的状态...是打开还是关闭?

I need to check my folder''s status...that is it opened or closed?

推荐答案

这不是一件容易的事。更少来自c#。

你必须列出所有打开的文件句柄,并搜索你要监视的文件夹。

这是一个VC教程:列出使用的文件 [ ^ ]
您可以从代码中运行此命令行应用程序,并解析结果: http://technet.microsoft.com/en-us/sysinternals/bb896655.aspx [ ^ ]



但是应该是你想要的那个。 https://github.com/o2platform/O2.Platform。脚本/ blob / master / APIs / Windows / Win32 / API_Win32Processes_Handles.cs [ ^ ]



在每种情况下都要确保,您拥有提升的权限!



[更新]

让我们假设这不是你想要的。我有另一个想法:由于Windows资源管理器和Internet Explorer具有相同的核心,您可以列出它们的所有打开的实例,并查看哪些URL是打开的。您甚至可以区分这两种情况。请参阅以下简短的示例代码:

http://omegacoder.com/?p=63 [ ^ ]
It is not an easy task. Even less from c#.
You have to list all opened file handles, and search for the folder you want to monitor.
This is a VC tutorial: Listing Used Files[^]
You can run this command line application from your code, and parse the result: http://technet.microsoft.com/en-us/sysinternals/bb896655.aspx[^]

But thsi should be the one you wanted. https://github.com/o2platform/O2.Platform.Scripts/blob/master/APIs/Windows/Win32/API_Win32Processes_Handles.cs[^]

In every case make sure, you have elevated privileges!

[Update]
Let''s suppose this is not what you want. I have an other idea: since Windows Explorer and Internet Explorer have the same core, you have the possibility to list all opened instances of them and see what url''s are open. And you can even distinguish between the two scenarios. See this short articla and sample code:
http://omegacoder.com/?p=63[^]


A文件夹不能打开或关闭。这只不过是一个比喻。这没有什么是文件夹的属性。如果你的意思是显示的文件夹是一些基于Shell的文件管理器(或不是),这是该管理器状态的一部分,而不是文件夹本身。



解决方案一解释了一个非常不同的东西:文件系统对象可以有一个当前由某个进程使用的句柄。有可能找出哪个进程处理哪个句柄。如果您需要找出阻止某些文件系统对象的内容(例如删除),则需要这样做。如果这是你需要的,那就去吧。但请记住,正确提出问题非常重要。此外,在提问时解释你的最终目标很重要。这样,即使您有误解,您也有机会获得好的建议。由于大多数问题的作者确实存在一些误解,因此了解目标非常重要。



-SA
A folder cannot be "opened" or "closed". This is nothing more then a metaphor. Nothing like that is an attribute of a folder. If you mean the a folder is shown is some file manager based on Shell (or not), this is a part of state of this manager, not the folder itself.

Solution one explains a very different thing: a file system object can have a handle currently used by some process. It''s possible to find out which process holds which handles. This is needed if you need to find out what prevents some file system object from, for example, deletion. If this is what you need, go for it. But keep in mind that correct formulation of your questions is important. Besides, it''s important to explain your ultimate goals when asking a question. This way, you get a chance to receive a good advice even if you have a misconception. As authors of majority of questions do have some misconceptions, knowing the goal is important.

—SA


这篇关于如何检查资源管理器上是否打开了文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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