LPT并口zebra打印代码段
作者:互联网
1 class Printer 2 { 3 [DllImport("kernel32.dll", CharSet = CharSet.Auto)] 4 private static extern SafeFileHandle CreateFile(string lpFileName, int dwDesiredAccess, int dwShareMode, 5 int lpSecurityAttributes, int dwCreationDisposition, int dwFlagsAndAttributes, int hTemplateFile); 6 12 public static bool PrintLPT(string ZPL) 13 { 14 SafeFileHandle iHandle = CreateFile("LPT1", 0x40000000, 0, 0, 3, 0, 0); 15 16 if (!iHandle.IsInvalid) 17 { 18 FileStream fs = new FileStream(iHandle, FileAccess.ReadWrite); 19 StreamWriter sw = new StreamWriter(fs, Encoding.Default); 20 sw.WriteLine(ZPL); 21 sw.Close(); 22 fs.Close(); 23 return true; 24 } 25 else 26 { 27 return false; 28 } 29 } 30 }
标签:并口,int,LPT,sw,代码段,iHandle,fs,static,new 来源: https://www.cnblogs.com/lakeliu/p/11969021.html