打开资源管理器窗口,并等待它关闭 [英] Open explorer window and wait for it to close

查看:244
本文介绍了打开资源管理器窗口,并等待它关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个程序,是打开一个浏览器窗口到一个特定的文件夹,但我想执行操作的浏览器窗口关闭后的权利,但如果我用下面的代码:

I have a program that is opening an explorer window to a certain folder but i want to perform an action right after the explorer window is closed, but if I use the following code:

Process proc = Process.Start("explorer.exe", "D:\\");
proc.WaitForExit();



这是打开浏览器窗口根据需要而WaitForExit命令没有任何影响,它只是正确的过去吧。

It is opening the explorer window as desired but the WaitForExit command has no effect and it just goes right past it.

有没有打开资源管理器窗口,将能够让我知道什么时候被用户关闭以不同的方式?

Is there a different way of opening the explorer window that will be able to let me know when it is closed by the user?

推荐答案

不能再生的错误。只是尝试这样的:

Cannot regenerate the error. Just tried this:

Process.Start("explorer.exe", "D:\\").WaitForExit();

和它阻止当前线程并等待,直到我关闭资源管理器窗口。请确保你没有其他线程比你想阻止一个执行命令。

and it blocks the current thread and waits until I close the explorer windows. Make sure that you're not executing the command on another thread than the one you want to block. Also make sure that you set every instance of a window to start a new instance of explorer.exe via importing below .reg file:

Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer]
"DesktopProcess"=dword:00000001
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Explorer]
"DesktopProcess"=dword:00000001
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\BrowseNewProcess]
"BrowseNewProcess"="Yes"
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Explorer\BrowseNewProcess]
"BrowseNewProcess"="Yes"

您将需要重新启动计算机,这样才能生效。

You'll need to restart your computer for this to take effect.

这篇关于打开资源管理器窗口,并等待它关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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