[dllimport("kernel32.dll")]
private static extern int createfile(string lpfilename, uint dwdesiredaccess, int dwsharemode,
int lpsecurityattributes, int dwcreationdisposition, int dwflagsandattributes, int htemplatefile);
[dllimport("kernel32.dll")]
private static extern bool closehandle(int hobject);
#endregion
public enum horpos
private int ihandle;
private int colwidth = 32;
public bool open()
else
public bool writeline(string data)
public bool writeline(string data, horpos horpos)
return writeline(data);
}public bool close()
public bool printline()
public bool newrow()
);return result;
}public bool newrow(int irow)
return result;
}public bool cut*****());}
}public class printer
[structlayout(layoutkind.sequential)]
public struct printer_info_2
#endregion
#region 引用 windowsapi
//引用api宣告
[dllimport("winspool.drv", charset = charset.auto, setlasterror = true)]
[return: marshalas(unmanagedtype.bool)]
private static extern bool enumprinters(printerenumflags flags, string name, uint level,
intptr pprinterenum, uint cbbuf, ref uint pcbneeded,
ref uint pcreturned);
#endregion
public static string getprinter()
}return result;
}#region 託管**
///
/// 遍歷印表機
///
///
///
public static printer_info_2 enumprinters(printerenumflags flags)
marshal.freehglobal(paddr);
}return info2;
}#endregion
}呼叫**:
//不用驅動的話,不判斷是否存在印表機。
if (printer.getprinter() == null || printer.getprinter().length == 0)
state = "正在列印...";
trylpt.newrow();
lpt.writeline("合計:".padright(8, ' ') + labcount.text.padleft(11, ' '));
lpt.printline();
lpt.printdate();
lpt.cut*****();
lpt.close();
system.threading.thread.sleep(500);
state = "列印完成...";
}catch (exception ex)
如果沒有安裝印表機驅動程式,呼叫的時候,一定要保證印表機聯機。
適用於56-58mm的紙
python escpos 小票 列印 機
python escpos 佳博 gp l80180i 可以使用 pip install python escpos from escpos.printer import serial ser serial com3 38400 timeout 1 ser.text hello world n se...
c 餐飲系統印表機 C 呼叫小票印表機
using system using system.collections.generic using system.componentmodel using system.data using system.drawing using system.text using system.drawin...
印表機驅動 報錯 正在列印
2 注意 設定埠。開啟控制面板 裝置和印表機,找到對應型號印表機,右鍵選擇 印表機屬性 檢視 埠 選項,預設是選擇lpt1埠,如果是usb轉接線使用usb001之類的埠 如果遇到報錯 正在列印 1 開啟 服務 找到print spooler,停止該服務 2 ctrl r開啟執行,輸入spool,刪除...