Freigeben über


Launching the Internet Properties dialog from C#

If for some reason you need to show the Internet Properties dialog from your managed app you have two choices:

1. Launch the CPL file using the file association. The only caveat of doing this is that the dialog is modeless and will stay up even after your process dies. The way you would do this is:

Process.Start(Environment.GetEnvironmentVariable("windir") + "\\system32\\inetcpl.cpl");

2. The second method involves p-invoking into the library that contains the dialog. This is pretty much what IE is doing. Below’s the pinvoke signature and a sample call.

[DllImport("inetcpl.cpl", SetLastError = true)]

public static extern int LaunchInternetControlPanel(IntPtr hWnd);           

// Launch the IE internet properties as a modal dialog for this winform

LaunchInternetControlPanel(this.Handle);

 The inetcpl.cpl module isn’t on PInvoke.net. I did send some mail to Adam Nathan so it should be up there eventually.

Comments