c# - 通过 C# 显示 "Devices and Printers"窗口?

标签 c# windows

如何使用 C# 显示“设备和打印机”窗口,如此屏幕截图所示?

enter image description here

最佳答案

应用程序可以通过执行 control.exe 以编程方式打开控制面板in a new process . MSDN states调用控制面板项的首选方法是使用其规范名称,该名称是非本地化的并且跨版本稳定。从 Windows Vista 开始,每个控制面板项都有一个规范的名称; MSDN 提供a list对于标准 Windows 控制面板项目。此列表表明设备和打印机 项目的规范名称是Microsoft.DevicesAndPrinters .

可以通过调用 control.exe 在新进程中打开控制面板项目以规范名称作为参数(/name <canonical name or GUID>):

//note: assumes (using System.Diagnostics and System.IO)

string controlpath = Path.Combine(
    Environment.GetFolderPath(Environment.SpecialFolder.System),
    "control.exe"); // path to %windir%\system32\control.exe
                    // (ensures the correct control.exe)

Process.Start(controlpath, "/name Microsoft.DevicesAndPrinters");

关于c# - 通过 C# 显示 "Devices and Printers"窗口?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17339243/

相关文章:

java - java应用程序无缘无故无响应

c++ - 通过组策略安装 VC++ 可再发行组件的最佳方法是什么?

asp.net - 使用 Active Directory/LDAP 的表单例份验证

c# - 如何使 Winforms 表单终止应用程序?

c# - 将枚举序列化为 XML 属性

c# - 具有多个参数的 Task.Factory.StartNew

c++ - Windows 性能调整的资源建议(实时)

c# - ASP.NET 中的 Windows 时区缩写

c# - LINQ EF 未保存到数据库

java - 对于 Windows Xp 和 Windows 7,从 "My Documents"访问文件时出错