首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

vb调用c写的dll有关问题

2012-02-25 
高手请进vb调用c写的dll问题vb6.0activeXdll控件用处:在jsp页面中用javascript调用.类模块代码:(声明为lon

高手请进vb调用c写的dll问题
vb6.0
activeX   dll控件
用处:在jsp页面中用javascript调用.
类模块代码:(声明为long的,在c++写的dll里面是int型的,String在dll中是指针类型的,不知对不??????)
  Private   Declare   Function   ykt_opencard   Lib   "c:\windows\system32\YKTClient.dll "   (ByVal   nDeviceType   As   Long,   ByVal   nCom   As   Long,   ByVal   nBaud   As   Long,   pRegion   As   String,   pErrmsg   As   String)   As   Long
  Private   Declare   Function   ykt_readopeninitcardno   Lib   "c:\windows\system32\YKTClient.dll "   (pRegion   As   String,   pDeptid   As   String,   pDeptpass   As   String,   pCardno   As   String,   pCardtype   As   String,   pErrmsg   As   String)   As   Long
  Private   Declare   Function   ykt_closecard   Lib   "c:\windows\system32\YKTClient.dll "   (pErrmsg   As   String)   As   Long
 
'这个模块是个类模块,为什么上面的语名不能声明为public,在网上看到的例子都是声明为public的?????????????
'目前提示找不到YKTClient.dll文件,不加路径也一样,dll放在system32目录下????????????????

'编写activeX   dll,然后在网页上调用。是不是代码写在类模块里面,还是模块里面,(初学者,望高手指教)

Public   cardno   As   String

Public   Function   openCard()   As   Long

      Dim   nDeviceType   As   Long
     
      Dim   nCom   As   Long
      Dim   nBaud   As   Long
      Dim   pRegion   As   String
      Dim   pDeptid   As   String
      Dim   pDeptpass   As   String
      Dim   pCardno   As   String
      Dim   pCardtype   As   String
      Dim   pErrmsg   As   String
      Dim   flag   As   Long
     
    nDeviceType   =   10
    nCom   =   9
    nBaud   =   1
    pRegion   =   "XM "
    pErrmsg   =   " "
    flag   =   ykt_opencard(nDeviceType,   nCom,   nBaud,   pRegion,   pErrmsg)
   
End   Function

Public   Function   readCard()   As   Long
     
      Dim   pRegion   As   String
      Dim   pDeptid   As   String
      Dim   pDeptpass   As   String
      Dim   pCardno   As   String
      Dim   pCardtype   As   String
      Dim   pErrmsg   As   String
      Dim   flag   As   Long
     
    flag   =   openCard()
    If   flag   =   0   Then
    pRegion   =   "XM "
    pDeptid   =   "0606 "
    pDeptpass   =   "11111111 "
    pCardno   =   " "
    pCardtype   =   " "
    pErrmsg   =   " "
    flag   =   ykt_readopeninitcardno(pRegion,   pDeptid,   pDeptpass,   pCardno,   pCardtype,   pErrmsg)


                If   flag   =   0   Then
                            cardno   =   pCardno
                            flag   =   closeCard()
                Else
                            flag   =   closeCard()
                End   If
    End   If
End   Function
Public   Function   closeCard()   As   Long
      Dim   pErrmsg   As   String
      Dim   flag   As   Long
    pErrmsg   =   " "
    flag   =   ykt_closecard(pErrmsg)
End   Function




[解决办法]
如果C中String是指针类型的话,在VB中String也要定义为ByVal,因为VB中String是指针存储的。

热点排行