unsigned long comlpt_send(unsigned long handle, unsigned char * buf, unsigned long dwSize);/*
comlpt_read 从通信口接收数据
返回值 : 成功接收的实际字节数  参数如下:
handle : 由 comlpt_init 获得的返回值
buf    : 数据空间指针首地址
dwSize : 数据空间实际字节数
 
*/
上面的函数,用vb怎么传直?关键是 buf 这个变量

解决方案 »

  1.   

    我用vb是这样操作的
      先引用api  
     Declare Function comlpt_send lib "ComLpt.dll"(byval handle as long,byref buf as Byte,byval dwSize as integer)  as integer 再调用
      private  sub command1_click()
        dim buu() as byte    dim str as string
        str="测试数据"
        buu=StrConv(str,vbFromUnicode)
       comlpt_send(ihandle,buu,4)
        
       end sub
      

  2.   

    试试:Declare Function comlpt_send lib "ComLpt.dll"(byval handle as long,byref  buf as Byte,byval dwSize as LONG) AS LONG调用:
    private sub command1_click()
    dim buu() as bytedim str as string
    str="测试数据"
    buu=StrConv(str,vbFromUnicode)
    comlpt_send(ihandle,buf(0),4)end sub
      

  3.   

    谢谢 faysky2(出来混,迟早是要还嘀)  调用现在不报错, 前进了一步,但是还是不行
      

  4.   

    comlpt_send(ihandle,buf(0),4)为什么不用
    comlpt_send(ihandle,buf(0),lenb(buf))
      

  5.   

    lenb(buf) 这个函数如果我这样用dim buu() as byte
    dim i as inter
    buu=StrConv(str,vbFromUnicode)
    i=lenb(buu)'这里报错,说 要求变量-不能赋值到该表达试
    comlpt_send(ihandle,buf(0),i)
      

  6.   

    请为你的数组增加一个元素,最后一个元素的数值请赋0。当然4是不够的请测试8或9(因为不知道该API对长度的计算是否包括尾部的元素。)。