How to open the control panel programmatically?

How can I open a custom control panel programmatically, for example custom.cpl? In particular, how do I open 64-bit cpl when working as a 32-bit application?

+3
source share
5 answers

Vista has added support for canonical names, so you do not need to write DLL file names and tab indices

Example: WinExec ("% systemroot% \ system32 \ control.exe / name Microsoft.WindowsUpdate", SW_NORMAL);

(Names are always in English)

See MSDN for a list.

XP/2000 "control.exe mouse" , . MSDN (, , control.exe)

+5

SO, :

  • "control", :
::ShellExecute(m_hWnd, NULL, _T("control.exe"), _T("access.cpl"), NULL, SW_SHOW);
+5

1:                        .                2:                        ControlPanel

            **Process.Start(System.Environment.SystemDirectory + @"\appwiz.cpl");**
+1

:

"Start Control" "Control" , .

.

This code (Bellow) worked fine for me:

public Form1()
{
     InitializeComponent();
}

    #region Variables
    Process p;
    #endregion Variables

    [...]

    void myMethod()
    {
            try
            {
                p = new Process();
                p.StartInfo.FileName = "cmd.exe";
                p.StartInfo.RedirectStandardInput = true;
                p.StartInfo.RedirectStandardOutput = true;
                p.StartInfo.CreateNoWindow = true;
                p.StartInfo.UseShellExecute = false;
                p.Start();

                p.StandardInput.WriteLine("start control"); 
                p.StandardInput.Flush();
                p.StandardInput.Close();
                Console.WriteLine(p.StandardOutput.ReadToEnd());
            }
            catch (Exception ex) { MessageBox.Show(ex.Message); }
    }
0
source

just use it ....

ProcessStartInfo startInfo = new ProcessStartInfo("appwiz.cpl");
startInfo.UseShellExecute = true;
Process.Start(startInfo);
0
source

Source: https://habr.com/ru/post/1702585/


All Articles