There are two ways using C# that I found on the net:
Using CreateFile and WriteFile from win32 api:
[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 ")] privatestaticextern bool WriteFile( int hFile, byte[] lpBuffer, int nNumberOfBytesToWrite, ref int lpNumberOfBytesWritten, ref OVERLAPPED lpOverlapped ); iHandle =CreateFile("lpt1 ",0x40000000,0,0,3,0,0);
byte[] mybyte =System.Text.Encoding.Default.GetBytes(Mystring); bool b =WriteFile(iHandle, mybyte, mybyte.Length,ref i,ref x);
It can transport barcode command and print barcode well, but it can not read the status from the parallel port.
Using Inpout32.dll: There are two main functions:
short Inp32(short PortAddress)
void Out32(short PortAddress, short data)
But the parameter's type is short
; how can I transfer print command String at a time?
现在都用英文提问问题了,时尚啊。
原先是在stackoverflow上提的问,懒得翻译就直接粘过来了