TSC条码打印机C#例程(tsclib.dll调用)

//----  program.cs

using System;
using System.Collections.Generic;
using System.Windows.Forms;

using System.Runtime.InteropServices;
public class TSCLIB_DLL
{
 [DllImport("TSCLIB.dll", EntryPoint = "about")]
    public static extern int about();

[DllImport("TSCLIB.dll", EntryPoint = "openport")]
    public static extern int openport(string printername);

[DllImport("TSCLIB.dll", EntryPoint = "barcode")]
    public static extern int barcode(string x, string y, string type,
                string height, string readable, string rotation,
                string narrow, string wide, string code);

[DllImport("TSCLIB.dll", EntryPoint = "clearbuffer")]
    public static extern int clearbuffer();

[DllImport("TSCLIB.dll", EntryPoint = "closeport")]
    public static extern int closeport();

[DllImport("TSCLIB.dll", EntryPoint = "downloadpcx")]
    public static extern int downloadpcx(string filename, string image_name);

[DllImport("TSCLIB.dll", EntryPoint = "formfeed")]
    public static extern int formfeed();

[DllImport("TSCLIB.dll", EntryPoint = "nobackfeed")]
    public static extern int nobackfeed();

[DllImport("TSCLIB.dll", EntryPoint = "printerfont")]
    public static extern int printerfont(string x, string y, string fonttype,
                    string rotation, string xmul, string ymul,
                    string text);

[DllImport("TSCLIB.dll", EntryPoint = "printlabel")]
    public static extern int printlabel(string set, string copy);

[DllImport("TSCLIB.dll", EntryPoint = "sendcommand")]
    public static extern int sendcommand(string printercommand);

[DllImport("TSCLIB.dll", EntryPoint = "setup")]
    public static extern int setup(string width, string height,
              string speed, string density,
              string sensor, string vertical,
              string offset);

[DllImport("TSCLIB.dll", EntryPoint = "windowsfont")]
    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
    {
        /// <summary>
        /// 應用程式的主要進入點。
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
    }
}

//----Form1.cs

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace TSCLIB_DLL_IN_C_Sharp
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

private void button1_Click(object sender, EventArgs e)
        {
            //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
           
        }
    }
}

//------ 另例

[System.Runtime.InteropServices.DllImport("tsclib.dll")]
  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();
  }

TSC条码打印机C#例程(tsclib.dll调用)的更多相关文章

  1. TSC条码打印机C#例程(tsclib.dll调用) 【转】

    //----  program.cs using System;using System.Collections.Generic;using System.Windows.Forms; using S ...

  2. DLL放在指定目录 以及设置dll调用路径

    一.DLL放在指定目录 在编写C# winform程序中,不免一个项目会有多个工程文件,而这些工程文件之间是相互引用的,所以不想将工程的生成结果(exe或者dll)放在当前工程bin目录下的Debug ...

  3. zw版【转发·台湾nvp系列Delphi例程】.NET调用HALCON COM控件内存释放模式

    zw版[转发·台湾nvp系列Delphi例程].NET调用HALCON COM控件内存释放模式 ------------------------------------方法一 :Imports Sys ...

  4. opencv通过dll调用matlab函数,图片作为参数

    [blog 项目实战派]opencv通过dll调用matlab函数,图片作为参数                   前文介绍了如何“csharp通过dll调用opencv函数,图片作为参数”.而在实 ...

  5. csharp通过dll调用opencv函数,图片作为参数

    [blog 项目实战派]csharp通过dll调用opencv函数,图片作为参数          ​一直想做着方面的研究,但是因为这个方面的知识过于小众,也是由于自己找资料的能力比较弱,知道今天才找 ...

  6. C++ dll调用-动态(显式)

    C++ dll调用-动态(显式) 废话不说上代码, dll 头文件 j_test.h #pragma once extern "C"_declspec(dllexport) voi ...

  7. DLL调用的两种方式(IDE:VC6.0,C++)

    原文:http://www.cnblogs.com/Pickuper/articles/2050409.html DLL调用有两种方式,一种是静态调用,另外一种是动态调用 (一)静态调用 静态调用是一 ...

  8. C++ 多项目dll调用-隐式

    将DAA人脸检测做成动态库以便其他程序调用,采用隐式调用完成. 给出部分关于dll制作的关键代码: 1.DLL 多项目DLL编写注意将其他相关项目设置成静态库,以及各库涉及的版本一致性. DLL.h ...

  9. delphi 跨版本DLL调用嵌入窗体实现

    delphi 能实现把别的DLL的窗体句柄查到后,贴到PANL之中,此类文章网上不少,而如果是delphi不同版本开发的DLL互调时,一些控件内部的定义有所区别,因为无法(至少目前我觉得理论上不可行) ...

随机推荐

  1. 算法笔试题整理——升级蓄水池 && 字符串数字表达式计算值 && 求旅游完所有景点需要的最少天数 && 宝箱怪

    1. 小米笔试题——升级蓄水池 题目描述: 在米兔生活的二维世界中,建造蓄水池非常简单. 一个蓄水池可以用n个坐标轴上的非负整数表示,代表区间为[0-n]范围内宽度为1的墙壁的高度. 如下图1,黑色部 ...

  2. WinForm界面开发之 启动界面

    我们在开发桌面应用程序的时候,由于程序启动比较慢,往往为了提高用户的体验,增加一个闪屏,也就是SplashScreen,好处有:1.让用户看到加载的过程,提高程序的交互响应:2.可以简短展示或者介绍程 ...

  3. 宝塔Linux常用命令

    https://www.bt.cn/bbs/thread-1186-1-1.html 2017年3月8日发布全新架构的宝塔Linux 面板3.1Beta版,到现在的5.2.0正式版,历经100多天打磨 ...

  4. CCF CSP 201609-4 交通规划

    CCF计算机职业资格认证考试题解系列文章为meelo原创,请务必以链接形式注明本文地址 CCF CSP 201609-4 交通规划 问题描述 G国国王来中国参观后,被中国的高速铁路深深的震撼,决定为自 ...

  5. 【HackerRank】How Many Substrings?

    https://www.hackerrank.com/challenges/how-many-substrings/problem 题解 似乎是被毒瘤澜澜放弃做T3的一道题(因为ASDFZ有很多人做过 ...

  6. USACO 5.3 Window Area

    Window AreaIV Balkan Olympiad You've just be assigned the project of implemented a windowing interfa ...

  7. hdoj1879 继续畅通工程(Prime || Kruskal)

    题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=1879 思路 这题和hdoj1102很像,图中的有一些路已经修好了,对于这些已经修好的路,我们令还需要修 ...

  8. ES6-const注意

    注意要点 const 如何做到变量在声明初始化之后不允许改变的?其实 const 其实保证的不是变量的值不变,而是保证变量指向的内存地址所保存的数据不允许改动.此时,你可能已经想到,简单类型和复合类型 ...

  9. 【运维实战】一次linux日志分割之路——将日志按照每小时进行分割,并按照“日期-小时”格式保存

    是这样的,现在需要对nginx的access.log进行按照每小时进行分割,并且最好还要能够以 “日期+时间”的形式,命名保存. 两点,一个是按照每小时进行分割,一个是将日志以“日期+时间”的形式进行 ...

  10. CentOS6启动流程(含详细流程图)

    参考:Linux启动流程和grub详解(作者:好笔记运维) 为什么把这位的参考放在前面,主要是这位大佬的流程图太详细了.虽说不一定要了解这么详细,但还是很佩服啊.不多说,上图(在新标签中打开图片) 下 ...