c#开发一个zebar105sl的条码打印的程序

 最近有个项目设及到要开发一个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);
}

}

 

 

但我不是很明白,我已经在自己的机器上装上了打印机的驱动测试页都没问题,现在不知到怎么把信息传给打印机,然后让打印机工作!有高手来一起讨论一下吗?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值