5

如何以编程方式打开自定义控制面板,例如 custom.cpl?具体来说,作为 32 位应用程序运行时,如何打开 64 位 cpl?

4

5 回答 5

5

由于我在 SO 上没有找到好的答案,因此这是我的研究的解决方案:

  • 启动一个新的应用程序“control”,它将控制面板的名称作为其第一个参数:
::ShellExecute(m_hWnd, NULL, _T("control.exe"), _T("access.cpl"), NULL, SW_SHOW);
于 2009-02-02T15:49:03.970 回答
5

Vista 添加了对规范名称的支持,因此您不必对 dll 文件名和选项卡索引进行硬编码

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

(名字总是英文)

有关列表,请参阅MSDN

XP/2000 支持“control.exe 鼠标”和其他一些关键字,请参阅相同的 MSDN 页面以获取列表(您可以通过在 control.exe 上运行字符串来找到一些未记录的关键字)

于 2009-02-16T02:46:31.670 回答
3

就用这个....

ProcessStartInfo startInfo = new ProcessStartInfo("appwiz.cpl");
startInfo.UseShellExecute = true;
Process.Start(startInfo);
于 2016-01-08T14:25:11.453 回答
1

Step1 : 从机器上读取系统目录。Step2 : 使用 Process 启动 ControlPanel

            **Process.Start(System.Environment.SystemDirectory + @"\appwiz.cpl");**
于 2011-12-28T11:49:03.500 回答
1

正如我之前在另一个问题中提到的:

如果您在命令提示符中键入“开始控制”或“控制”,它将打开控制面板。

因此只需运行一个进程。

这段代码(波纹管)对我来说非常有效:

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); }
    }
于 2015-03-20T01:09:12.200 回答