gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-11-01 09:40:50 25 4
gpt4 key购买 nike

如何使用 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com