모델 이름을 확인하고 싶지는 않습니다. 대신 프린터를 제어하는 드라이버를 확인합니다. ZPL 가능 프린터가 Zebra 프린터 드라이버를 사용하려고합니다. 그리고 아래에 설명 된대로 drivername 속성을 확인할 수 있습니다. 물론 해당 프린터에 대해 더 많은 속성을 사용할 수 있습니다.
using System;
using System.Management;
namespace Test
{
class Program
{
public static void Main(string[] args)
{
string query = string.Format("SELECT * from Win32_Printer");
ManagementObjectSearcher searcher = new ManagementObjectSearcher(query);
ManagementObjectCollection coll = searcher.Get();
foreach (ManagementObject printer in coll)
{
//foreach (PropertyData property in printer.Properties)
//{
// Console.WriteLine(string.Format("{0}: {1}", property.Name, property.Value));
//}
var property = printer.Properties["DriverName"];
if (property.Value.ToString().ToLowerInvariant().Contains("zebra"))
{
Console.ForegroundColor = ConsoleColor.Red;
Console.Write("ZEBRA: ");
}
else
{
Console.ForegroundColor = ConsoleColor.Gray;
Console.Write("Regular: ");
}
Console.WriteLine(string.Format("{0}: {1}", property.Name, property.Value));
}
Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
}
}
}
자동 검색은 제대로 작동하지 않습니다. * 두 대의 프린터를 사용할 수 있다면 어떨까요? 이것은 프린터 이름으로 구성되거나 사용자가 PrintDialog로 프린터를 선택하도록해야합니다. –