In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces how to use the Lpt port printing class in C#, which is very detailed and has a certain reference value. Friends who are interested must finish reading it!
What is the operation of the C#LPT port print class? First of all, let's take a look at what is the LPT port (for printers)? LPT port is an enhanced bi-directional parallel transmission interface. Before the emergence of USB interface, it was the most commonly used interface for scanners and printers. * the transmission speed is 1.5Mbps, and the device is easy to install and use, but the speed is relatively slow. The following are specific examples of C#LPT port printing:
Summary description of using System; using System.Runtime.InteropServices; using System.IO; namespace printBarcode {/ LPTControl, operation of C#LPT port print class / public class LPTControl {public LPTControl () {} [StructLayout (LayoutKind.Sequential)] private struct OVERLAPPED {int Internal; int InternalHigh; int Offset; int OffSetHigh; int hEvent } [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")] private static extern bool WriteFile (int hFile, byte [] lpBuffer, int nNumberOfBytesToWrite, ref int lpNumberOfBytesWritten, ref OVERLAPPED lpOverlapped) [DllImport ("kernel32.dll")] private static extern bool CloseHandle (int hObject); / / Operation of C#LPT port printing class private int iHandle; public bool Open () {iHandle=CreateFile ("lpt1", 0x40000000); if (iHandle! =-1) {return true;} else {return false }} public bool Write (String Mystring) {if (iHandle! =-1) {int ionomo; OVERLAPPED x=new OVERLAPPED (); byte [] mybyte= System.Text.Encoding.Default.GetBytes (Mystring); return WriteFile (iHandle,mybyte,mybyte.Length,ref iJournal ref x);} else {throw new Exception ("Port not open!");}} public bool Close () {return CloseHandle (iHandle) }} / / the operation of the C#LPT port print class} the above is all the contents of the article "how to use the Lpt Port print Class in C#". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.