`........
implementation
function getfonthex(pch_text,pch_font:pchar;int_fontsize,int_x,int_y,intstyle:integer;var ary_byt:array of byte):integer;stdcall;external '.\ttftohex.dll' name 'getfonthex';
{$R *.DFM}
...
...
procedure TTEC_DLL.btn_CallDllClick(Sender: TObject);
var    
      ary_byt1: array [0..51200] of byte;
      int_bufsize of integer;
 begin
      int_bufsize:=getfonthex('DLL示例 ','黑体',50 ,20,20,0,ary_byt1);  //汉字存入ary_byt1缓存中
END.
我用vb改写了
'在公共模块中的声明
Public Declare Function getfonthex Lib "ttftohex.dll" (ByVal outStr As String, ByVal lfFaceName As String, ByVal lfStrSize As Long, ByVal lfXcoordinates As Long, ByVal lfYCoordinates As Long, ByVal lfStyle As Long, ByRef hexBuf() As String) As Integer'窗体中的调用
Private Sub Command1_Click()    Dim array1(0 To 51200) As String
    Dim int_size As Long    int_size = getfonthex("DLL", "黑体", 20, 20, 20, 0, array1)End Sub
====================================
问题是我在vb中调用getfonthex程序就回异常中断退出,各位达人我改写的有问题吗?

解决方案 »

  1.   

    * Function in ttftohex.dll ;
    *   getfonthex       -  - Get bitmap in hex code of specific out
    *                         string and font to buffer.
    *     Parameter:
    *       1) LPSTR outStr,              // output string   字符串  (或单色bmp文件名称)
    *       2) LPSTR lfFaceName,          // Windows font name  字体名称 (或指定为 BITMAP)
    *       3) int   lfStrSize,           // string size (in 0.1mm units, in 0.05mm units if
                                          // the printer resolution is 600dpi )  字体大小(单位 0.1mm,若打印机为600DPI,则单位为0.05mm)
    *       4) int   lfXCoordinates,      // x-coordinates of print origin for drawing  打印开始位置X坐标
    *       5) int   lfYCoordinates,      // y-coordinates of print origin for drawing  打印开始位置Y坐标
    *       6) int   lfstyle,             // font style 0:normal,1:bold ,2:Italic,3:underline,4:strikeout  字形
    *       7) LPSTR hexBuf               // buffer to receive hex codes,
    *                                        buffer size has better less than 100k    接收缓冲区:字符以16进制存储 Buffer最好小于100K
    *    int Return : Byte count of buffer contents if successful     返回值: Buffer的大小
    *
    * Note : 1) Before program to call function getfonthex in ttftohex.dll,
    *           Statement must be added to declare it in the call program.
    *        2) Function name getfonthex must in lower case.
    *        3) Before function getfonthex() is called, the buffer 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 buffer.
    *           The total number of byte output in buffer is return by getfonthex().
    =========================================
    这是ttftohex.dll 的说明
      

  2.   

    var ary_byt:array of byte 改成了 ByRef hexBuf() As String 这里有问题吧
      

  3.   

    var ary_byt:array of byte 改成了 ByRef hexBuf() As String 这里有问题吧严重支持liangqingzhi(老之)