VC dll 中ULONG类型的参数VB中应该用什么类型?

testpwd 2010-06-01 03:43:09
用VC写的一个dll,导出函数如下:

HRESULT func(ULONG & errNum);

在VB中声明如下:

private declare function func lib "example.dll" (byref errNum as Long) as Long

dim errNum as long

result = func(errNum)

最后得到errNum是-1,这明显是不对的。请问VC中的ULONG类型VB中应该用Long吗?
...全文
98 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
Forrest23 2010-06-01
  • 打赏
  • 举报
回复
vb中就用long 如果是vb.net 应该用Integer
oo渣渣oo 2010-06-01
  • 打赏
  • 举报
回复
很久前写的一个过程了,有点不合理,给你参考一下:

Public Overloads Shared Sub Byte2Decimal(ByRef intResult As Integer, ByVal byteSource() As Byte, ByVal iStrIndex As Integer, ByVal iEndIndex As Integer, Optional ByVal blnHighFront As Boolean = True)
Dim strResult As String = String.Empty
Byte2DecimalBase(strResult, byteSource, iStrIndex, iEndIndex, blnHighFront)
If IsNumeric(strResult) Then
intResult = CInt(strResult)
Else
intResult = 0
End If
End Sub

Public Overloads Shared Sub Byte2Decimal(ByRef lngResult As Long, ByVal byteSource() As Byte, ByVal iStrIndex As Integer, ByVal iEndIndex As Integer, Optional ByVal blnHighFront As Boolean = True)
Dim strResult As String = String.Empty
Byte2DecimalBase(strResult, byteSource, iStrIndex, iEndIndex, blnHighFront)
If IsNumeric(strResult) Then
lngResult = CLng(strResult)
Else
lngResult = 0
End If
End Sub


Private Shared Sub Byte2DecimalBase(ByRef strResult As String, ByVal byteSource() As Byte, ByVal iStrIndex As Integer, ByVal iEndIndex As Integer, Optional ByVal blnHighFront As Boolean = True)
If iEndIndex >= iStrIndex Then
Dim sTmp As String = String.Empty
Dim sResult As String = String.Empty
Dim I As Integer
If blnHighFront Then
For I = iStrIndex To iEndIndex
sTmp = Hex(byteSource(I))
sTmp = StrDup(2 - sTmp.Length, "0") & sTmp
sResult = sResult & sTmp
Next
Else
For I = iEndIndex To iStrIndex Step -1
sTmp = Hex(byteSource(I))
sTmp = StrDup(2 - sTmp.Length, "0") & sTmp
sResult = sResult & sTmp
Next
End If
strResult = CLng("&H" & sResult).ToString
sTmp = Nothing
sResult = Nothing
I = Nothing
Else
strResult = "0"
End If
End Sub

testpwd 2010-06-01
  • 打赏
  • 举报
回复
如果是负值的话应该如何处理一下呢?还原成正确的值?比如得到的结果是-1,真正的值应该是多少呢?
oo渣渣oo 2010-06-01
  • 打赏
  • 举报
回复
还是用Byte数组吧,到时候自己解析,万能滴......呵呵
gxingmin 2010-06-01
  • 打赏
  • 举报
回复
一般就是用long

16,554

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧