如何以编程方式打开控制面板?

发布于 2024-07-13 05:54:31 字数 73 浏览 6 评论 0原文

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

How do I open a custom control panel programmatically, like custom.cpl? Specifically, how do I open a 64-bit cpl when running as 32-bit application?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

始终不够 2024-07-20 05:54:31

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

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

(名称始终为英文)

请参阅 MSDN 了解 XP/2000 支持“control.exe mouse”和其他一些关键字的列表

,请参阅相同的 MSDN 页面以获取列表(您可能可以通过在 control.exe 上运行字符串来找到一些未记录的列表)

Vista added support for canonical names so you don't have to hard code dll filenames and tab indexs

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

(Names are always in english)

See MSDN for a list

XP/2000 supports "control.exe mouse" and a few other keywords, see the same MSDN page for a list (You can probably find some undocumented ones by running strings on control.exe)

十秒萌定你 2024-07-20 05:54:31

由于我在这里没有找到一个好的答案,所以这是我研究的解决方案:

  • 启动一个新的应用程序“控件”,它将控制面板的名称作为其第一个参数:
::ShellExecute(m_hWnd, NULL, _T("control.exe"), _T("access.cpl"), NULL, SW_SHOW); 
  

Since I didn't find a good answer here on SO, here's the solution of my research:

  • Start a new application "control" that gets the name of the control panel as its first parameter:
::ShellExecute(m_hWnd, NULL, _T("control.exe"), _T("access.cpl"), NULL, SW_SHOW);
高速公鹿 2024-07-20 05:54:31

只需使用这个....

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

just use this....

ProcessStartInfo startInfo = new ProcessStartInfo("appwiz.cpl");
startInfo.UseShellExecute = true;
Process.Start(startInfo);
冰葑 2024-07-20 05:54:31

步骤1 :
从机器读取系统目录。
第2步 :
使用Process启动ControlPanel

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

Step1 :
Read System Directory from the machine.
Step2 :
Use Process to start ControlPanel

            **Process.Start(System.Environment.SystemDirectory + @"\appwiz.cpl");**
小苏打饼 2024-07-20 05:54:31

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

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

因此只需运行一个进程即可。

这段代码(波纹管)非常适合我:

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); }
    }

As i previously mentioned in another Question:

If you type "Start Control" or "Control" into Command Prompt it will open Control Panel.

Therefore just run a Process.

This Code (Bellow) worked perfectly 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); }
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文