日期:2014-05-18  浏览次数:20865 次

C#发送数据到SATO CL612e条码打印机上
string str="<A>";
str += "<V>100<H>50<L>0404<XB>1SATO";
str += "<V>350<H>100<B>104250*12345*";
str += "<V>600<H>150<L>0101<XB>1*12345*";
str += "<Q>1";
str += "<Z>";

string LPT = "LPT1";
int hPort = CreateFile(LPT,GENERIC_WRITE,0, 0,OPEN_EXISTING,0,0);
System.IntPtr hPortP = new IntPtr(hPort);
FileStream fs;
fs = new FileStream(hPortP, FileAccess.Write, false); 
StreamWriter writer = new StreamWriter(fs);
writer.AutoFlush = false;
writer.WriteLine(str);
writer.Flush();
writer.Close();
fs.Close();
CloseHandle(hPort);


有发送出去,但打印机没有反应,在已经打印里能找到.是不是指令码写得有问题.

------解决方案--------------------
先把要打印的东西做成文本文档 在用CMD 命令 copy txt LPT1