//必须将fnthex32.dll 与执行文件放在同一路径下(....\bin\....),无需添加引用. 将项目以类库的形式生成.那么在外部只需添加此类库,//调用方法进行打印即可.using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.IO;using System.Runtime.InteropServices;namespace BarCode{ public class BarCode { [System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential)] private struct OVERLAPPED { int Internal; int InternalHigh; int Offset; int OffSetHigh; int hEvent; } [System.Runtime.InteropServices.DllImport("kernel32.dll")] private static extern int CreateFile(string lpFileName, uint dwDesiredAccess, int dwShareMode, int lpSecurityAttributes, int dwCreationDisposition, int dwFlagsAndAttributes, int hTemplateFile); [System.Runtime.InteropServices.DllImport("kernel32.dll")] private static extern bool WriteFile(int hFile, byte[] lpBuffer, int nNumberOfBytesToWrite, out int lpNumberOfBytesWritten, out OVERLAPPED lpOverlapped); [System.Runtime.InteropServices.D
自定义的BarCode,封装进行斑马打印的信息
最新推荐文章于 2023-03-27 11:39:10 发布
本文介绍了如何在C#中创建一个自定义的BarCode类,利用fnthex32.dll进行斑马打印机的条形码打印。通过Open、Write和Close方法与LPT1端口交互,实现打印指令的发送。
摘要由CSDN通过智能技术生成