这个dll怎么用啊??(100分)

  • 主题发起人 主题发起人 hfjacklee
  • 开始时间 开始时间
H

hfjacklee

Unregistered / Unconfirmed
GUEST, unregistred user!
这是一个关于斑马条码打印机函数的声明:

Function in FNTHEX.DLL:
* GETFONTHEX() - Get bitmap in hex code of specific out
* string and font to buffer.
* Parameter:
* 1) LPSTR outStr, // output string
* 2) LPSTR lfFaceName, // Windows font name
* 3) LPSTR outstrname // output string name
* 4) short int lfOrientation, // clock-wish Orientation: 0,90,180,270
* 5) short int lfHeight, // font height
* 6) short int lfWidth, // font width, always set to 0
* 7) short int lfBold, // bold font style
* 8) short int lfItalic, // italic font style
* 9) LPSTR hexBuf // buffer to receive hex codes,
* size must set to 21K.
* Return : Byte count of buffer contents if successful, otherwise <= 0
*
* Note : 1) Before program to call function GETFONTHEX() in FNTHEX32.DLL,
* Statement must be added to declare it in the call program.
* 2) Function name GETFONTHEX() must in upper case.
* 3) Before function GETFONTHEX() is called, the buffer that is equal
* to 21K must to allocate first.
* 4) The return of GETFONTHEX() is greate than 0 if function call is
* successful, and result of Chinese data is stored in 21K buffer.
* The total number of byte output in buffer is return by GETNFONTHEX().
* 5) Printer driver "Generic / Text Only" must be set for
* label printing under Windows 32 bit environment.

这是在vb中的例子
Private Declare Function GETFONTHEX Lib "fnthex32.dll" (ByVal chnstr$, ByVal fontname$, ByVal chnname$, ByVal orient%, ByVal height%, ByVal width%, _
ByVal bold%, ByVal italic%, ByVal hexbuf$) As Integer

Private Sub Command1_Click()
Dim MAX_BUFFER As Integer, nCount As Integer
Dim cBuf As String * 21000
Dim I As Integer

nCount = GETFONTHEX("钙奶片", "宋体", "chnstr01", 0, 50, 0, 1, 0, cBuf)
Printer.Print Mid(cBuf, 1, nCount)
Printer.EndDoc
nCount = GETFONTHEX("金额(¥)", "宋体", "chnstr02", 0, 40, 0, 1, 0, cBuf)
Printer.Print Mid(cBuf, 1, nCount)
Printer.EndDoc
nCount = GETFONTHEX("三联商业公司", "宋体", "chnstr03", 0, 40, 0, 1, 0, cBuf)
Printer.Print Mid(cBuf, 1, nCount)
Printer.EndDoc
nCount = GETFONTHEX("银座超市", "宋体", "chnstr04", 0, 40, 0, 1, 0, cBuf)
Printer.Print Mid(cBuf, 1, nCount)
Printer.EndDoc

Printer.Print "^XA^LH10,10"
Printer.Print "^FO100,20^XGchnstr01,1,1^FS"
Printer.Print "^FO20,100^BEN,60,Y,N^FD123456789012^FS"
Printer.Print "^FO50,200^XGchnstr02,1,1^FS"
Printer.Print "^FO250,200^A040,40^FD2.20^FS"
Printer.Print "^FO50,250^XGchnstr03,1,1^FS"
Printer.Print "^FO50,300^XGchnstr04,1,1^FS"
Printer.Print "^PQ1^FS"
Printer.Print "^XZ"
Printer.EndDoc

可是我怎么都无法转换到delphi中来。急啊!!!(分不多了)

 
可以改为直接用delphi的控件:
http://www.8421.org/download.php?id=180
 
这个dll是厂商提供的可以在斑马(zebra)系列条码打印机上直接输出!不可以用通用的
,可惜是厂商只提供了vb的例程!
 
希望既懂vb又熟delphi的朋友援手!谢了!谢了!谢了!
 
function GETFONTHEX(outStr: PChar;
lfFaceName: PChar;
outstrname: PChar;
lfOrientation: SmallInt;
lfHeight: SmallInt;
lfWidth: SmallInt;
lfBold: SmallInt;
lfItalic: SmallInt;
hexBuf: PChar): Integer;
external 'fnthex32.dll';

调用如:
var
nCount: Integer
cBuf: array[1..21000] of Char;

nCount = GETFONTHEX('钙奶片', '宋体', 'chnstr01', 0, 50, 0, 1, 0, cBuf)

定义中SmallInt是否要改为ShortInt或者Integer,自己试试看。
 
按照如上调用:
在nCount:= GETFONTHEX('钙奶片', '宋体', 'chnstr01', 0, 50, 0, 1, 0, cBuf);

Incompatible types: 'Array' and 'PChar'
我改写成在nCount:= GETFONTHEX('钙奶片', '宋体', 'chnstr01', 0, 50, 0, 1, 0, pchar(cBuf));
也不行!
 
我可以把这个dll发给你qdyoung,你试试好么。
 
搞错了,应该是 @cBuf
 
我这儿没delphi :(
 
我按你说得改了
在nCount:= GETFONTHEX('钙奶片', '宋体', 'chnstr01', 0, 50, 0, 1, 0, @cBuf);
可是运行竟然报地址错误在user32.dll昏倒。不是delphi的问题。好像是指针的问题啊
 
把定义里面的SmallInt全部改为Integer试试

把定义里面的SmallInt全部改为ShortInt再试试
 
我也正研究ZEBRA呢!hfjacklee你那弄的怎么样了!哪个DLL,如何得到?我的邮箱:
wsqrock@sina.com
http://www.delphibbs.com/delphibbs/dispq.asp?lid=1268085
 
qdyoung, 应该对呀,你是否可以考虑如此改以下:
function GETFONTHEX(outStr: PChar;
lfFaceName: PChar;
outstrname: PChar;
lfOrientation: SmallInt;
lfHeight: SmallInt;
lfWidth: SmallInt;
lfBold: SmallInt;
lfItalic: SmallInt;
hexBuf: PChar): Integer;cdecl ;//<<---------一般用C++做的DLL可能存在传递参数顺序的问题
external 'fnthex32.dll';

调用如:
var
nCount: Integer
cBuf: array[1..21000] of Char;

nCount = GETFONTHEX('钙奶片', '宋体', 'chnstr01', 0, 50, 0, 1, 0, @cBuf);


 
我也正在研究条码打印,你这个Dll是从哪得到的?告诉我,一起研究。
 
我最近刚做好了一个条码打印程序,是专门针对斑马Z4M的。你把这个DLL发给我吧。我会把全部源码给你的。谢了
1979mylove@163.com
 
后退
顶部