Open Internet Properties and wait until user close it C#

会有一股神秘感。 提交于 2019-12-07 16:21:54

问题


Is there any possibility to open Internet Properties window..
Code:

System.Diagnostics.Process p;
p = System.Diagnostics.Process.Start("InetCpl.Cpl", ",4");

..and wait until user close it? (and then check internet connection and continue)

This code not work:

p.WaitForExit();

I think this problem is related to Open explorer window and wait for it to close but solution for this contains only tips specific for windows explorer browser window.

Can I do this in C#?

Solution
Someone put here (only for a short moment) this full command how to open Internet Properties window:

C:\Windows\system32\rundll32.exe C:\Windows\system32\shell32.dll,Control_RunDLL C:\Windows\system32\inetcpl.cpl,,4

I tried it .. and really .. it works!

System.Diagnostics.Process p;
p = System.Diagnostics.Process.Start("rundll32.exe",
    @"C:\Windows\system32\shell32.dll,Control_RunDLL"
    + " C:\Windows\system32\inetcpl.cpl,,4");
p.WaitForExit();
MessageBox.Show("Properties closed");

I get "Properties closed" message only after I close Properties window.
No PID needed .. easy and perfectly elegant solution.
If the user that wrote the original response with this command write it again, I accept his solution.


回答1:


Use the below Code to open control panel in separate process:

System.Diagnostics.Process.Start(@"C:\Windows\system32\rundll32.exe"
    , @"C:\Windows\system32\shell32.dll,Control_RunDLL"
    + " C:\Windows\system32\inetcpl.cpl,,4");

and then you can WaitForExit();



来源:https://stackoverflow.com/questions/17553209/open-internet-properties-and-wait-until-user-close-it-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!