C++有这样的一个函数,在VB中如何定义这个API呢?//向网关提交消息
int CMPP_Submit(
            int conn_id,INT64 *msg_id,unsigned char msg_level,
     char *service_id,unsigned char msg_format,char *msg_src,
            char *fee_type,char *fee_code,char *valid_time,char *at_time,
      unsigned char tp_pid,unsigned char tp_udhi,unsigned char fee_usertype,
            char *charge_mobile,char *src_mobile,unsigned char user_num,
            char *dest_mobiles,char *msg,int  msg_len, unsigned char need_response);

解决方案 »

  1.   

    这个可能不行吧,INT64, 这些vb都没有对应的类型可以试一下
    declare fucntion CMPP_submit(byval conn_id as long, msg_id as any, byval msg_level as byte, byval service_id as string, ......)
      

  2.   

    Public Declare Function CMPP_submit Lib "your.dll" Alias "CMPP_submit" (....) As Long
      

  3.   

    首先,这个函数必须是 __stdcall。
    public declare function CMPP_Submit lib "你的库文件名" ( _
    byval conn_id as long, byref msg_id as currency,byval msg_level as byte, _
    byval service_id as string,byval msg_format as byte,byval msg_src as string, _
    byval fee_type as string,byval fee_code as string,byval valid_time as string, _
    byval at_time as string,byval tp_pid as byte,byval tp_udhi as byte, _
    byval fee_usertype as byte,byval charge_mobile as string,byval src_mobile as string, _
    byval user_num as byte,byval dest_mobiles as string,byval msg as string, _
    byval msg_len as long, byval need_response as byte) as long凡是声明为 byval xx as string 的,也可以声明成 byref xx() as byte, 尤其是数据中含有值大于 127 的字节时。
      

  4.   

    使用of123() 的方法报:"DLL 调用约定错误"
    我编译成EXE后,执行此方法报内存错误
      

  5.   

    使用of123() 的方法报:"DLL 调用约定错误"
    我编译成EXE后,执行此方法报内存错误
      

  6.   

    调用约定错误? 应该使用stdcall方式的
    看参数是否对应一致
      

  7.   

    CMPPAPIDef.h文件里的定义原样如下(我没有原代码的)
    //向网关提交消息
    int CMPP_Submit(
                int conn_id,INT64 *msg_id,unsigned char msg_level,
         char *service_id,unsigned char msg_format,char *msg_src,
                char *fee_type,char *fee_code,char *valid_time,char *at_time,
          unsigned char tp_pid,unsigned char tp_udhi,unsigned char fee_usertype,
                char *charge_mobile,char *src_mobile,unsigned char user_num,
                char *dest_mobiles,char *msg,int  msg_len, unsigned char need_response);我在VB中的用了两种方式定义:
    Public Declare Function CMPP_Submit Lib "CMPPAPI.dll" (ByVal actId As Long, ByRef msgId As Currency, _
        ByVal msg_level As Byte, ByVal service_id As String, ByVal msg_format As Byte, _
        ByVal msg_src As String, ByVal fee_type As String, ByVal free_code As String, _
        ByVal valid_time As String, ByVal at_time As String, ByVal tp_pid As Byte, _
        ByVal tp_udhi As Byte, ByVal fee_usertype As Byte, ByVal charge_mobile As String, _
        ByVal src_mobile As String, ByVal user_num As Byte, ByVal dest_mobiles As String, _
        ByVal msg As String, ByVal msg_len As Long, ByVal need_response As Byte) As Long'Public Declare Function CMPP_Submit Lib "CMPPAPI.dll" ( _
    '        ByVal conn_id As Long, ByRef msg_id As Any, ByVal msg_level As Byte, _
    '        ByRef service_id() As Byte, ByVal msg_format As Byte, ByRef msg_src() As Byte, _
    '        ByRef fee_type() As Byte, ByRef fee_code() As Byte, ByRef valid_time() As Byte, _
    '        ByRef at_time() As Byte, ByVal tp_pid As Byte, ByVal tp_udhi As Byte, _
    '        ByVal fee_usertype As Byte, ByRef charge_mobile() As Byte, ByRef src_mobile() As Byte, _
    '        ByVal user_num As Byte, ByRef dest_mobiles() As Byte, ByRef msg() As Byte, _
    '        ByVal msg_len As Long, ByVal need_response As Byte) As Long当调用此函数过程没有报错.但是在接着的代码中就不能进行其他操作如果进行了操作有两种情况:
    (两种情况都是在EXE中执行)
    1. if result >0 then
          s = s & "成功!"
       else
          s =s & "失败"
     
    报内存错误2.call log("成功")
    报错:未设置对象变量或 With block 变量
      

  8.   

    不知道INT64是什么定义,就有可能内存错误。
      

  9.   

    "DLL 调用约定错误"还是 __stdcall 的问题。如果 C 中的函数没有声明成__stdcall,VB 就无法调用。
    如果你没有源码,只有一个办法,再用 C 写一个__stdcall DLL 库函数作“二传手”,VB 调用它,它调用目标函数。
      

  10.   

    dll 怎么做,我搞了半天,最后还是编译不了
    http://community.csdn.net/Expert/topic/4126/4126385.xml?temp=.8292505