TSC条码打印机C#例程(tsclib.dll调用) 【转】
2021-06-08 23:04
标签:close generic ble read services down dia -- window TSC条码打印机C#例程(tsclib.dll调用) //---- program.cs using System; using System.Runtime.InteropServices; [DllImport("TSCLIB.dll", EntryPoint = "openport")] [DllImport("TSCLIB.dll", EntryPoint = "barcode")] [DllImport("TSCLIB.dll", EntryPoint = "clearbuffer")] [DllImport("TSCLIB.dll", EntryPoint = "closeport")] [DllImport("TSCLIB.dll", EntryPoint = "downloadpcx")] [DllImport("TSCLIB.dll", EntryPoint = "formfeed")] [DllImport("TSCLIB.dll", EntryPoint = "nobackfeed")] [DllImport("TSCLIB.dll", EntryPoint = "printerfont")] [DllImport("TSCLIB.dll", EntryPoint = "printlabel")] [DllImport("TSCLIB.dll", EntryPoint = "sendcommand")] [DllImport("TSCLIB.dll", EntryPoint = "setup")] [DllImport("TSCLIB.dll", EntryPoint = "windowsfont")] //----Form1.cs using System; namespace TSCLIB_DLL_IN_C_Sharp private void button1_Click(object sender, EventArgs e) //------ 另例 [System.Runtime.InteropServices.DllImport("tsclib.dll")] TSC条码打印机C#例程(tsclib.dll调用) 【转】 标签:close generic ble read services down dia -- window 原文地址:https://www.cnblogs.com/liujianshe1990-/p/10676388.html
using System.Collections.Generic;
using System.Windows.Forms;
public class TSCLIB_DLL
{
[DllImport("TSCLIB.dll", EntryPoint = "about")]
public static extern int about();
public static extern int openport(string printername);
public static extern int barcode(string x, string y, string type,
string height, string readable, string rotation,
string narrow, string wide, string code);
public static extern int clearbuffer();
public static extern int closeport();
public static extern int downloadpcx(string filename, string image_name);
public static extern int formfeed();
public static extern int nobackfeed();
public static extern int printerfont(string x, string y, string fonttype,
string rotation, string xmul, string ymul,
string text);
public static extern int printlabel(string set, string copy);
public static extern int sendcommand(string printercommand);
public static extern int setup(string width, string height,
string speed, string density,
string sensor, string vertical,
string offset);
public static extern int windowsfont(int x, int y, int fontheight,
int rotation, int fontstyle, int fontunderline,
string szFaceName, string content);
}
namespace TSCLIB_DLL_IN_C_Sharp
{
static class Program
{
///
/// 應用程式的主要進入點。
///
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
{
//TSCLIB_DLL.about(); //Show the DLL version
TSCLIB_DLL.openport("TSC TTP-344M Plus"); //Open specified printer driver
TSCLIB_DLL.setup("100", "63.5", "4", "8", "0", "0", "0"); //Setup the media size and sensor type info
TSCLIB_DLL.clearbuffer(); //Clear image buffer
TSCLIB_DLL.barcode("100", "100", "128", "100", "1", "0", "2", "2", "Barcode Test"); //Drawing barcode
TSCLIB_DLL.printerfont("100", "250", "3", "0", "1", "1", "Print Font Test"); //Drawing printer font
TSCLIB_DLL.windowsfont(100, 300, 24, 0, 0, 0, "ARIAL", "Windows Arial Font Test"); //Draw windows font
TSCLIB_DLL.downloadpcx("UL.PCX", "UL.PCX"); //Download PCX file into printer
TSCLIB_DLL.sendcommand("PUTPCX 100,400,"UL.PCX""); //Drawing PCX graphic
TSCLIB_DLL.printlabel("1", "1"); //Print labels
TSCLIB_DLL.closeport(); //Close specified printer driver
}
}
}
private static extern void windowsfont(int a, int b, int c,int d,int e ,int f, string g ,string h);
[System.Runtime.InteropServices.DllImport("tsclib.dll")]
private static extern void openport(string printername);
[System.Runtime.InteropServices.DllImport("tsclib.dll")]
private static extern void closeport();
[System.Runtime.InteropServices.DllImport("tsclib.dll")]
private static extern void sendcommand(string command);
[System.Runtime.InteropServices.DllImport("tsclib.dll")]
private static extern void setup(string width,string height,string speed,string density,string sensor,string vertical,string offset);
[System.Runtime.InteropServices.DllImport("tsclib.dll")]
private static extern void clearbuffer();
[System.Runtime.InteropServices.DllImport("tsclib.dll")]
private static extern void printlabel(string Set,string Copy);
private void button1_Click(object sender, System.EventArgs e)
{
openport("TSC TTP-343");
setup("100","65","3","10","0","3","0");
clearbuffer();
windowsfont(50,30,70,0,0,0,"黑体","索书号:");
printlabel("1", "1");
closeport();
}
上一篇:C# 霍尼韦尔扫码枪扫码打印
文章标题:TSC条码打印机C#例程(tsclib.dll调用) 【转】
文章链接:http://soscw.com/essay/92414.html