我有一台 DNP DS620 照片打印机,我需要定期检查其状态(剩余打印件和状态消息,例如正常或卡纸)。 Windows 打印机设置菜单显示的信息如所附屏幕截图所示。
还有一个 DNP 工具已经查询了上述信息:http://dnpphoto.com/Portals/0/Resources/PrinterInfo_1.2.1.1.zip
但是,该工具在启动时会显示警告,提示不要在打印时使用它,这对于自动后台使用可能不是最佳选择。而且,无论如何,这个应用程序都没有接口。
我感谢任何关于如何解决这个问题的想法。
你是怎么解决的?我尝试如上所述通过 c# 获取数据,但 GetMediaCounter 的输出是“-1”。
我的代码:
[DllImport("c:\test\\CspStat.dll")]
private static extern int GetMediaCounter(int portno);
[DllImport("c:\test\\CspStat.dll")]
private static extern int GetPrinterPortNum(byte[] name, int a);
foreach (string printer in System.Drawing.Printing.PrinterSettings.InstalledPrinters){
//Printer name is "DP-DS620"
if (printer.Contains("DP")) {
//Port return 1, if i change the second parameter to something else the return is 0
MessageBox.Show(printer + ": Port: " + GetPrinterPortNum(Encoding.ASCII.GetBytes(printer), 0).ToString());
//Returns always -1
MessageBox.Show(GetMediaCounter(GetPrinterPortNum(Encoding.ASCII.GetBytes(printer), 0)).ToString());
}
else
MessageBox.Show(printer);
}
谢谢, 朱利安