如何在我的WPF应用程序中检测打印机EPSON TM T88v(基于热敏打印机COM端口) [英] How to detect printer EPSON TM T88v ( Thermal printer COM port based) in my WPF application

查看:217
本文介绍了如何在我的WPF应用程序中检测打印机EPSON TM T88v(基于热敏打印机COM端口)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

EPSON TM T88v是热感POS打印机.我需要在WPF应用程序中检测到它已连接到PC,因此可以向它发送打印命令.

解决方案

参考:使用系统; 使用System.Management; 命名空间zedilabs.com { 类PrinterOffline { [STAThread] 静态void Main(string [] args) { //设置管理范围 ManagementScope范围=新的ManagementScope(@"\ root \ cimv2"); scope.Connect(); //从WMI对象集合中选择打印机 ManagementObjectSearcher搜索器=新 ManagementObjectSearcher("SELECT * FROM Win32_Printer"); 字符串printerName ="; foreach(searcher.Get()中的ManagementObject打印机) { printerName = printer ["Name"].ToString().ToLower(); 如果(printerName.Equals(@"hp deskjet 930c")) { Console.WriteLine(打印机=" +打印机[名称"])); if(printer ["WorkOffline"].ToString().ToLower().Equals("true"))) { //打印机被用户离线 Console.WriteLine(未连接您的即插即用打印机."); } 别的 { //打印机不离线 Console.WriteLine(您的即插即用打印机已连接."); } } } } } }

并检查这些.

如何使用C#检查打印机是否已连接

https://www.codeproject .com/Articles/6069/如何使用C检查您的打印机是否已连接

检查打印机是否连接到PC

https://stackoverflow.com/questions/26710810/check -打印机是否连接到PC或不连接

最好的问候,

Bob


EPSON TM T88v is a thermal POS printer. I need to detect in my WPF application that it is connected to my PC so I can send print command to it. How do I do this?

解决方案

Hi,

Reference: https://social.msdn.microsoft.com/Forums/vstudio/en-US/67d43a94-ef0e-4ea6-adbf-795835047d73/how-get-physical-printer-is-connected-or-not-in-c?forum=csharpgeneral

using System;
using System.Management; 
namespace zedilabs.com
{
 class PrinterOffline
 {
  [STAThread]
  static void Main(string[] args)
  {
   // Set management scope
   ManagementScope scope = new ManagementScope(@"\root\cimv2");
   scope.Connect();

   // Select Printers from WMI Object Collections
   ManagementObjectSearcher searcher = new 
    ManagementObjectSearcher("SELECT * FROM Win32_Printer");

   string printerName = "";
   foreach (ManagementObject printer in searcher.Get()) 
   {
    printerName = printer["Name"].ToString().ToLower();
    if (printerName.Equals(@"hp deskjet 930c"))
    {
     Console.WriteLine("Printer = " + printer["Name"]); 
     if (printer["WorkOffline"].ToString().ToLower().Equals("true"))
     {
      // printer is offline by user
      Console.WriteLine("Your Plug-N-Play printer is not connected.");
     }
     else
     {
      // printer is not offline
       Console.WriteLine("Your Plug-N-Play printer is connected.");
     }
    }
   }
  }
 }
}

And check these.

How to Check if your Printer is Connected, using C#

https://www.codeproject.com/Articles/6069/How-to-Check-if-your-Printer-is-Connected-using-C

Check printer if connected to pc or not

https://stackoverflow.com/questions/26710810/check-printer-if-connected-to-pc-or-not

Best Regards,

Bob


这篇关于如何在我的WPF应用程序中检测打印机EPSON TM T88v(基于热敏打印机COM端口)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆