条码打印机DLL调用方法.ppt

上传人:本田雅阁 文档编号:3209091 上传时间:2019-07-31 格式:PPT 页数:31 大小:2.15MB
返回 下载 相关 举报
条码打印机DLL调用方法.ppt_第1页
第1页 / 共31页
条码打印机DLL调用方法.ppt_第2页
第2页 / 共31页
条码打印机DLL调用方法.ppt_第3页
第3页 / 共31页
条码打印机DLL调用方法.ppt_第4页
第4页 / 共31页
条码打印机DLL调用方法.ppt_第5页
第5页 / 共31页
点击查看更多>>
资源描述

《条码打印机DLL调用方法.ppt》由会员分享,可在线阅读,更多相关《条码打印机DLL调用方法.ppt(31页珍藏版)》请在三一文库上搜索。

1、动态链接库DLL的使用,1 动态链接库的概念 2 动态链接库的优点 3 DLL指令 4 Visual Basic 5.0, 6.0 下TSC函式库的应用 5 FoxPro下TSC函式库的应用 6 Delphi下TSC函式库的应用,请在使用TSCLIB.DLL之前 安装打印机驱动,1 动态链接库的概念,动态链接库(Dynamic Link Library,缩写为DLL)是一个可以被其它应用程序共享的程序模块,其中封装了一些可以被共享的例程和资源。动态链接库文件的扩展名一般是dll,也有可能是drv、sys和fon,它和可执行文件(exe)非常类似,区别在于DLL中虽然包含了可执行代码却不能单独执

2、行,而应由Windows应用程序直接或间接调用。 动态链接所调用的函数代码并没有被拷贝到应用程序的可执行文件中去,而是仅仅在其中加入了所调用函数的描述信息(往往是一些重定位信息)。仅当应用程序被装入内存开始运行时,在Windows的管理下,才在应用程序与相应的DLL之间建立链接关系。当要执行所调用DLL中的函数时,根据链接产生的重定位信息,Windows才转去执行DLL中相应的函数代码。,2 动态链接库的优点,1. 共享代码、资源和数据 使用DLL的主要目的就是为了共享代码,DLL的代码可以被所有的Windows应用程序共享。 2. 隐藏实现的细节 DLL中的例程可以被应用程序访问,而应用程序

3、并不知道这些例程的细节。 3. 拓展开发工具如Delphi的功能 由于DLL是与语言无关的,因此可以创建一个DLL,被C+、VB或任何支持动态链接库的语言调用。这样如果一种语言存在不足,就可以通过访问另一种语言创建的DLL来弥补。,说明: 指定计算机端的输出端口,参数:a:单机打印时,请指定打印机驱动程序名称, 例如: TSC TTP/TDP-243(E) 若连接打印机服务器,请指定服务器路径及共享 打印机 名称, 例如: SERVERTTP243,3 DLL指令,3.1 openport(a),3.2 closeport(),说明: 关闭指定的计算机端输出端口 参数: 无,3.3 Setup

4、(a,b,c,d,e,f,g),说明: 设定卷标的宽度、高度、打印速度、打印浓度、感应器类别、gap/black mark 垂直间距、gap/black mark 偏移距离) 参数: a: 字符串型别,设定卷标宽度,单位 mm b: 字符串型别,设定卷标高度,单位 mm c: 字符串型别,设定打印速度,(打印速度随机型不同而有不同的选项) 1.0: 每秒1.0吋打印速度 1.5: 每秒1.5吋打印速度 2.0: 每秒2.0吋打印速度 3.0: 每秒3.0吋打印速度 4.0: 每秒4.0吋打印速度 5.0: 每秒5.0吋打印速度 6.0: 每秒6.0吋打印速度 d: 字符串型别,设定打印浓度,0

5、15,数字愈大打印结果愈黑 e: 字符串型别,设定使用感应器类别 0 表示使用垂直间距传感器(gap sensor) 1 表示使用黑标传感器(black mark sensor) f: 字符串型别,设定gap/black mark 垂直间距高度,单位: mm g: 字符串型别,设定gap/black mark 偏移距离,单位: mm,此参数若 使用一般卷标时均设为0,3.4 clearbuffer(),说明: 清除 参数: 无,3.5 barcode(a,b,c,d,e,f,g,h,I) (1),说明: 使用条形码机内建条形码打印 参数: a: 字符串型别,条形码X方向起始点,以点(point

6、)表示。 (200 DPI,1点=1/8 mm, 300 DPI,1点=1/12 mm) b: 字符串型别,条形码Y方向起始点,以点(point)表示。 (200 DPI,1点=1/8 mm, 300 DPI,1点=1/12 mm) c: 字符串型别, 128 Code 128, switching code subset A, B, C automatically 128M Code 128, switching code subset A, B, C manually. EAN128 Code 128, switching code subset A, B, C automatically

7、 25 Interleaved 2 of 5 25C Interleaved 2 of 5 with check digits 39 Code 39 39C Code 39 with check digits 93 Code 93,EAN13 EAN 13 EAN13+2 EAN 13 with 2 digits add-on EAN13+5 EAN 13 with 5 digits add-on EAN8 EAN 8 EAN8+2 EAN 8 with 2 digits add-on EAN8+5 EAN 8 with 5 digits add-on CODA Codabar POST Po

8、stnet UPCA UPC-A UPCA+2 UPC-A with 2 digits add-o UPCA+5 UPC-A with 5 digits add-on UPCE UPC-E UPCE+2 UPC-E with 2 digits add-on UPCE+5 UPC-E with 5 digits add-on,3.5 barcode(a,b,c,d,e,f,g,h,I) (2),d: 字符串型别,设定条形码高度,高度以点来表示 e: 字符串型别,设定是否打印条形码码文 0: 不打印码文 1: 打印码文 f: 字符串型别,设定条形码旋转角度 0: 旋转0度 90: 旋转90度 18

9、0: 旋转180度 270: 旋转270度 g: 字符串型别,设定条形码宽窄bar 比例因子,请参考TSPL使用手册 h: 字符串型别,设定条形码宽窄bar 比例因子,请参考TSPL使用手册 I: 字符串型别,条形码内容,3.5 barcode(a,b,c,d,e,f,g,h,I) (3),3.6 printerfont(a,b,c,d,e,f,g),说明: 使用条形码机内建文字打印 参数: a: 字符串型别,文字X方向起始点,以点(point)表示。 (200 DPI,1点=1/8 mm, 300 DPI,1点=1/12 mm) b: 字符串型别,文字Y方向起始点,以点(point)表示。

10、(200 DPI,1点=1/8 mm, 300 DPI,1点=1/12 mm) c: 字符串型别,内建字型名称,共12种。 1: 8*/12 2: 12*20 dots 3: 16*24 dots 4: 24*32 dots 5: 32*48 dots TST24.BF2: 繁体中文24*24 TST16.BF2: 繁体中文16*16 TTT24.BF2: 繁体中文24*24 (电信码) TSS24.BF2: 简体中文24*24 TSS16.BF2: 简体中文16*16 K: 韩文 24*24 L: 韩文 16*16 d: 字符串型别,设定文字旋转角度 0: 旋转0度 90: 旋转90度 18

11、0: 旋转180度 270: 旋转270度 e: 字符串型别,设定文字X方向放大倍率,18 f: 字符串型别,设定文字Y方向放大倍率,18 g: 字串型別,列印文字內容,3.7 sendcommand(command),说明: 送内建指令到条形码打印机 参数: 详细指令请参考TSPL,3.8 printlabel(a,b),说明: 打印卷标内容 参数: a: 字符串型别,设定打印卷标式数(set) b: 字符串型别,设定打印卷标份数(copy),3.9 downloadpcx(a,b),说明:下载单色PCX 格式图文件至打印机 参数: a: 字符串型别,文件名(可包含路径) b: 字符串型别,

12、下载至打印机内存内之文件 名(请使用大写档名),3.10 formfeed(),说明: 跳页,该函式需在setup后使用 参数: 无,3.11 nobackfeed(),说明: 设定纸张不回吐 参数: 无,3.12 windowsfont(a,b,c,d,e,f,g,h),说明: 使用Windows TTF字型打印文字 参数: a: 整数型别,文字X方向起始点,以点(point)表示。 b: 整数型别,文字Y方向起始点,以点(point)表示。 c: 整数型别,字体高度,以点(point)表示。 d: 整数型别,旋转角度,逆时钟方向旋转 0 - 0 degree 90- 90 degree 1

13、80- 180 degree 270- 270 degree e: 整数型别,字体外形 0- 标准(Normal) 1- 斜体(Italic) 2- 粗体(Bold) 3- 粗斜体(Bold and Italic) f: 整数型别, 底线 0- 无底线 1- 加底线 g: 字符串型别,字体名称。 如: Arial, Times new Roman, 细名体, 标楷体 h: 字符串型别,打印文字内容。,3.13 about(),说明: 显示DLL 版本号码 参数: 无,4.1 引言,4 Visual Basic 5.0, 6.0 下TSC函式库的应用,Visual Basic (简称VB)是一种

14、可视化的面向对象的编程语言,深受广大Windows程序员的喜爱。但和任何其它语言一样,VB并不能满足所有的编程需要,例如没有提供读写硬件端口、控制中断等硬件控制函数。而在一些工业控制场合,往往需要对硬件板卡进行读写操作,如果控制软件是采用VB编写的,就很有必要对其进行功能扩充,使其具有操作硬件的能力。因此,VB可以通过声明和执行DLL函数调用新硬件设备的DLL设备驱动函数 。,Private Declare Sub openport Lib “c:windowssystemtsclib.dll“ (ByVal PrinterName As String),动态库的路径,定义参数类型,函数,释放

15、,用Visual Basic的Declare语句声明要使用的DLL过程或数; 执行DLL子程序。 例如:,私有,声明,4.2 VB调用DLL函数的步骤,4.3 VB下的动态库函数声明(1),Private Declare Sub openport Lib “c:windowssystemtsclib.dll“ ( ByVal PrinterName As String) Private Declare Sub closeport Lib “c:windowssystemtsclib.dll“ () Private Declare Sub sendcommand Lib “c:windowssy

16、stemtsclib.dll“ ( _ ByVal command As String) Private Declare Sub setup Lib “c:windowssystemtsclib.dll“ ( _ ByVal LabelWidth As String, _ ByVal LabelHeight As String, _ ByVal Speed As String, _ ByVal Density As String, _ ByVal Sensor As String, _ ByVal Vertical As String, _ ByVal Offset As String) Pr

17、ivate Declare Sub downloadpcx Lib “c:windowssystemtsclib.dll“ ( _ ByVal Filename As String, _ ByVal ImageName As String),Private Declare Sub barcode Lib “c:windowssystemtsclib.dll“ ( ByVal X As String, _ ByVal Y As String, _ ByVal CodeType As String, _ ByVal Height As String, _ ByVal Readable As Str

18、ing, _ ByVal rotation As String, _ ByVal Narrow As String, _ ByVal Wide As String, _ ByVal Code As String) Private Declare Sub printerfont Lib “c:windowssystemtsclib.dll“ (ByVal X As String, _ ByVal Y As String, _ ByVal FontName As String, _ ByVal rotation As String, _ ByVal Xmul As String, _ ByVal

19、Ymul As String, _ ByVal Content As String),4.3 VB下的动态库函数声明(2),4.3 VB下的动态库函数声明(3),Private Declare Sub clearbuffer Lib “c:windowssystemtsclib.dll“ () Private Declare Sub printlabel Lib “c:windowssystemtsclib.dll“ ( _ ByVal NumberOfSet As String, _ ByVal NumberOfCopy As String) Private Declare Sub form

20、feed Lib “c:windowssystemtsclib.dll“ () Private Declare Sub nobackfeed Lib “c:windowssystemtsclib.dll“ () Private Declare Sub windowsfont Lib “c:windowssystemtsclib.dll“ ( _ ByVal X As Integer, _ ByVal Y As Integer, _ ByVal fontheight As Integer, _ ByVal rotation As Integer, _ ByVal fontstyle As Int

21、eger, _ ByVal fontunderline As Integer, _ ByVal FaceName As String, _ ByVal TextContent As String),4.4 指令具体使用,5 FoxPro下TSC函式库的应用,5.1 引言,FoxPro是基于WINDOWS操作系统下的一种数据库编写软件。现在比较盛行的是可视化的Visual FoxPro ,也简称 FoxPro 。 由于它能够运行在更廉价的、旧的硬件上,运行遗留下来的代码,而且仍然能够执行现代的编程语言希望实现的事务,它仍然是那些叛逆的组织、小型的资源有限的办公室、独立软件开发者以及很多政府和政府

22、运转机构的选择。,5.2 FoxPro范例(1),declare openport in c:windowssystemtsclib.dll string declare closeport in c:windowssystemtsclib.dll declare sendcommand in c:windowssystemtsclib.dll declare setup in c:windowssystemtsclib.dll string,string,string,string,string,string,string declare downloadpcx in c:windowssy

23、stemtsclib.dll string, string declare barcode in c:windowssystemtsclib.dll string,string,string,string,string,string,string,string,string declare printerfont in c:windowssystemtsclib.dll string,string,string,string,string,string,string declare clearbuffer in c:windowssystemtsclib.dll declare printla

24、bel in c:windowssystemtsclib.dll string,string,declare formfeed in c:windowssystemtsclib.dll declare nobackfeed in c:windowssystemtsclib.dll declare windowsfont in c:windowssystemtsclib.dll integer,integer,integer,integer,integer,integer, integer,string,string openport(“TSC TTP-243 Plus”) setup(“32“

25、,“25“,“2“,“10“,“0“,“0“,“0“) clearbuffer() barcode(“10“,“0“,“EAN13“,“80“,“1“,“0“,“2“,“4“,“123456789012“) windowsfont(10,100,50,0,0,0,“标楷体“,“标楷体字型“) printlabel(“1“,“1“) closeport(),5.2 FoxPro范例(2),8.6.1 引言,6 Delphi下TSC函式库的应用,Delphi是著名的Borland(现在已和Inprise合并)公司开发的可视化软件开发工具。 Delphi是一门真正的面向对象的开发工具,并且是完全的可

26、视化。 Delphi使用了真编译,可以让你的代码编译成为可执行的文件,而且编译速度非常快。 Delphi具有强大的数据库开发能力,可以让你轻松地开发数据库。,6.2 Delphi范例(1),procedure openport(PrinterName:pchar);stdcall;far; external tsclib.dll; procedure closeport; external tsclib.dll; procedure sendcommand(Command:pchar);stdcall;far;external tsclib.dll; procedure setup(Label

27、Width, LabelHeight, Speed, Density, Sensor, Vertical, Offset:pchar);tsdcall; far; external tsclib.dll; procedure downloadpcx(Filename,ImageName:pchar);stdcall;far; external tsclib.dll; procedure barcode(X, Y, CodeType, Height, Readable, Rotation, Narrow, Wide, Code :pchar); stdcall; far; external ts

28、clib.dll; procedure printerfont(X, Y, FontName, Rotation, Xmul, Ymul, Content:pchar); stdcall;far; external tsclib.dll; procedure clearbuffer; external tsclib.dll; procedure printlabel(NumberOfSet, NumberOfCopoy:pchar);stdcall; far; external tsclib.dll;,6.2 Delphi范例(2),procedure formfeed;external ts

29、clib.dll; procedure nobackfeed; external tsclib.dll procedure windowsfont (X, Y, FontHeight, Rotation, FontStyle, FontUnderline : integer; FaceName, TextContect:pchar);stdcall;far;external tsclib.dll; procedure TForm1.M_cancelClick(Sender: TObject); begin openport(TSC TTP-246M); Setup(110, 63, 3, 10

30、, 0, 0, 0); SendCommand(GAP 2 mm,0); ClearBuffer(); SendCommand(BOX 15,15,810,510,5); WindowsFont(50, 150, 40, 0, 0,0, Arial, LOT:); Barcode(50, 200, 39, 50, 0, 0, 2, 4, 123456); WindowsFont(490,150, 40, 0, 0,0, 宋体, TSC条形码打印机); Barcode(520, 200, 39, 50, 0, 0, 2, 4, 123456); printlabel(1,1); closeport; end;,

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 其他


经营许可证编号:宁ICP备18001539号-1