最近有个项目设及到要开发一个zebar105sl的条码打印的程序,以前没有接触过这类东西,不知道哪位牛哥能给些支持,在网上开到有高手提供的一段程序,内容如下:
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace Barcode_Print
{
class LPTControl
{
[StructLayout(LayoutKind.Sequential)]
private struct OVERLAPPED
{
int Internal;
int InternalHigh;
int Offset; 字串6
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,
out int lpNumberOfBytesWritten,
out OVERLAPPED lpOverlapped
);
[DllImport("kernel32.dll")]
private static extern bool CloseHandle(
int hObject
);
private int iHandle;
public bool Open()
{
iHandle = CreateFile("lpt1", 0x40000000, 0, 0, 3, 0, 0);
字串3
if (iHandle != -1)
{
return true;
}
else
{
return false;
}
}
public bool Write(String Mystring)
{
if (iHandle != -1)
{
int i;
OVERLAPPED x;
byte[] mybyte = System.Text.Encoding.Default.GetBytes(Mystring);
return WriteFile(iHandle, mybyte, mybyte.Length, out i, out x);
}
else
{
throw new Exception("端口未打开!");
}
}
public bool Close()
{
return CloseHandle(iHandle);
}
}
但我不是很明白,我已经在自己的机器上装上了打印机的驱动测试页都没问题,现在不知到怎么把信息传给打印机,然后让打印机工作!有高手来一起讨论一下吗?
本文探讨了使用Zebar105SL进行条码打印的程序开发过程。作者分享了一段C#代码,用于通过打印机驱动发送打印指令,并寻求如何正确地将信息传递给打印机并使其工作的解决方案。
1989

被折叠的 条评论
为什么被折叠?



