CE 驱动并口打印机的问题
createfile方法可以将lpt端口打开,但是给打印机发数据打印机却没有反应,却没有返回错误,请问这是怎么回事,代码如下
public bool Open() { iHandle = CreateFile("lpt1:", 0x40000000, 0, 0, 3, 0, 0); if (iHandle != -1) { return true; } else { return false; } } //打印函数,参数为打印机的命令或者其他文本! public bool Write(string MyString) { if (iHandle != -1) { int i; OVERLAPPED x; int len=MyString.Length / 2; byte[] mybyte=new byte[len]; for (int j = 0; j < len; j++) { try { mybyte[j] = Convert.ToByte(MyString.Substring(j * 2, 2), 16); } catch(Exception ex) { mybyte[j] = 0; } } return WriteFile(iHandle, mybyte, mybyte.Length, out i, out x); } else { throw new Exception("端口未打开~!"); } }