Open the explorer window and wait for it to close.

I have a program that opens the explorer window to a specific folder, but I want to perform an action immediately after closing the explorer window, but if I use the following code:

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

It opens the explorer window at will, but the WaitForExit command has no effect, and it just goes right past it.

Is there any other way to open the explorer window that can tell me when it is closed by the user?

+3
source share
2 answers

Unable to repair error. Just tried this:

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

, . , , , . , explorer.exe . REG :

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"

.

+3

The Old New Thing:

, WaitForSingleObject , , Explorer - (, ). , , . WaitForSingleObject .

, , , ( PInvoke), , - this.

, - , , #, , .

+7

All Articles