发送指令到打印机 如何通过C#实现将变量形式的指令发送到条码打印机(艾利打印机),,有实例的给个实例,没有的给个实现的思路也好,,谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 如果有的话给我一个,不过建议楼主用Bartent软件进行条码打印,这款软件很好用的 貌似艾利打印机支持zpl语言,要是用LPT1端口打印的调用CreateFile API来生成文件,COM端口的直接发送到对应的COM口就好了(这种好像是要装驱动的) 是啊,调用完API中的CreateFile方法后,还需要调用一个向指定打印机发送这些指令的方法,类似于SendStringToPrinter(打印机,指令),在网上找了个API,可是里面没有这样的函数,, SafeFileHandle iHandle; iHandle = CreateFile("LPT1", GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0); if (iHandle.IsInvalid) { throw new Exception("Can't find the printer connecting to the port of LPT1"); } else { FileStream fs = new FileStream(iHandle, FileAccess.ReadWrite); byte[] byteOut; Int32 dwCount = as_str.Length; byteOut = new byte[dwCount]; for (int i = 0; i < dwCount; i++) { byteOut[i] = System.Convert.ToByte(as_str[i]); } fs.Write(byteOut, 0, dwCount); fs.Flush(); fs.Close(); } LPT1直接写文件流Flush()就可以了 http://download.csdn.net/detail/agatone/3508926这个现成的 WebServices上传文件出错! 记账凭证 我这样解释正确不? 请问这两种写法,哪个效率比较高? 这是什么原因造成的呀? 如何在InstallShield中调用Dotnet写的Dll? 大家看看这段代码哪里有问题??? 请教关于C#调用VC MFC ActiveX控件的问题 DATASET转换XML字符换的问题 大虾救命 datagrid 2个winForm窗体a,b,关闭b时,让a窗体中dataGridView控件刷新 C# Http Header的设置问题
不过建议楼主用Bartent软件进行条码打印,这款软件很好用的
iHandle = CreateFile("LPT1", GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0);
if (iHandle.IsInvalid)
{
throw new Exception("Can't find the printer connecting to the port of LPT1");
}
else
{
FileStream fs = new FileStream(iHandle, FileAccess.ReadWrite);
byte[] byteOut;
Int32 dwCount = as_str.Length;
byteOut = new byte[dwCount];
for (int i = 0; i < dwCount; i++)
{
byteOut[i] = System.Convert.ToByte(as_str[i]);
}
fs.Write(byteOut, 0, dwCount);
fs.Flush();
fs.Close();
}
这个现成的