弱弱的请教一下关于调用DLL的问题,请各位帮忙看看
收到一个加密用的DLL文件,一运行就VB就死掉,实在分析不出来是什么问题,请各位帮帮忙:
提供函数的文档上是:
函数原型:
void gen_digest(char * data ,int data_len,char *str_digest)
参数说明:
data:需要加密的数据项。
data_len:需加密数据长度。
str_digest:对数据加密后生成的校验码,长度为8个byte。
在使用时,将需要加密的数据按照相应的协议规则拚成data字符串,通过调用gen_digest即可得到固定长度为8个byte的校验码str_digest。
在程序中我是这样编写的:
Private Declare Function Plcz_cs Lib "c:\psw_en.dll" Alias "gen_digest" (ByVal Str_Cz As String, data_len As Integer, ByVal Str_Digest As String) As Long
Private Sub Command1_Click()
Dim RetStr As String, Str_Gen As String, Lng_Str As Long, i As Integer
Str_Gen = ""
RetStr = "123412340000212062310000.00"
i = Len(RetStr)
Lng_Str = Plcz_cs(RetStr, i, Str_Gen)
End Sub
[解决办法]
Private Declare Function Plcz_cs Lib "c:\psw_en.dll" Alias "gen_digest" (ByRef Str_Cz As Byte, data_len As Long, ByRef Str_Digest As Byte) As Long
Private Sub Command1_Click()
Dim RetStr As String, Str_Gen As String, Lng_Str As Long, i As Long
Dim RetByt() As Byte, Byt_Gen(7) AS Byte
RetStr = "123412340000212062310000.00"
i = Len(RetStr)
RetByt = StrConv(RetStr, vbFromUnicode)
Lng_Str = Plcz_cs(RetByt(0), i, Byt_Gen(0))
Str_Gen = StrConv(RetStr, vbUnicode)
End Sub