gpt4 book ai didi

c# - 如何在 C# 中查找打印机类型?

转载 作者:行者123 更新时间:2023-11-30 20:19:35 25 4
gpt4 key购买 nike

如何在 C# 中找到安装在我们 PC 中的打印机类型,是点阵式、激光式还是喷墨式?

最佳答案

下面的类(class)告诉你打印机是点阵式、激光式还是喷墨式:

using System;
using System.Management;

namespace ConsoleDemo
{
class Printer
{
public enum TechnologyType
{
Other = 1,
Unknown = 2,
Electrophotographic_LED = 3,
Electrophotographic_Laser = 4,
Electrophotographic_Other = 5,
Impact_Moving_Head_Dot_Matrix_9pin = 6,
Impact_Moving_Head_Dot_Matrix_24pin = 7,
Impact_Moving_Head_Dot_Matrix_Other = 8,
Impact_Moving_Head_Fully_Formed = 9,
Impact_Band = 10,
Impact_Other = 11,
Inkjet_Aqueous = 12,
Inkjet_Solid = 13,
Inkjet_Other = 14,
Pen_ = 15,
Thermal_Transfer = 16,
Thermal_Sensitive = 17,
Thermal_Diffusion = 18,
Thermal_Other = 19,
Electroerosion = 20,
Electrostatic = 21,
Photographic_Microfiche = 22,
Photographic_Imagesetter = 23,
Photographic_Other = 24,
Ion_Deposition = 25,
eBeam = 26,
Typesetter = 27
}

public static void GetPrinterInfo()
{
var printerQuery = new ManagementObjectSearcher("SELECT * from Win32_Printer");
foreach (var printer in printerQuery.Get())
{
var name = printer.GetPropertyValue("Name");
var status = printer.GetPropertyValue("Status");
var isDefault = printer.GetPropertyValue("Description");
var MarkingTechnology = printer.GetPropertyValue("MarkingTechnology");
var CurrentCapabilities = (string )printer.GetPropertyValue("CurrentCapabilities");
Console.WriteLine("Name:{0} |(Status: {1} | Description: {2}| Technology: {3} | {4} ",
name, status, isDefault, MarkingTechnology , CurrentCapabilities);
}
}

}

枚举 TechnologyType 为您提供打印机技术的类型。

欲了解更多信息,请查看:Win32_Printer class

关于c# - 如何在 C# 中查找打印机类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38419463/

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