Hi all,
I have an VB Active X dll, namely VBDLL.dll, with the following function declaration :
/////////////////////////////////////
Private Declare Function EncryptOnly Lib "CDLL.dll" _
Alias "_EncryptOnly@28" (ByVal CSN As String, _
ByVal CSNLen As Long, ByVal PlainTxt As String, _
ByVal PlainLen As Long, ByVal IV As String, _
ByVal CipherTxt As String, ByRef CipherLen As Long) As Long
/////////////////////////////////////
All the parameters are input parameters except the last two, which are CipherTxt and CipherLen that are output parameters.
(Notes : CDLL.dll is a C Win32 dll.)
The following function is in the Active X dll :
///////////////////////////////////////////////
Public Function Encrypt(ByVal CSN As String, _
ByVal CSNLen As Long, ByVal PlainTxt As String, _
ByVal PlainLen As Long, ByVal IV As String, _
CipherTxt As String, CipherLen As Long)
Dim CipherTxt1 As String
Dim CipherLen1 As Long
CipherTxt1 = String(2000, vbNullChar)
CipherLen1 = 2000
ReturnValue = EncryptOnly(CSN, CSNLen, PlainTxt, PlainLen, IV, CipherTxt1, CipherLen1)
CipherTxt = CipherTxt1
CipherLen = CipherLen1
End Function
/////////////////////////////////////////////////
When ASP page call the Encrypt function in the Active X dll, it can successfully pass in the input parameter.
The ASP codes snippet is as follows :
///////////////////////////////////////////////
Set g_oEracom = Server.CreateObject("VBDLL.CVBDLL"
g_oEracom.Encrypt g_sCSN, g_lngCSNLen, g_sPlainTxt, g_lngPlainLen, g_sIV, g_sCipherTxt, g_lngCipherLen
If Err.number <> 0 Then
Response.Write "Encrypt function failed!<br>"
Response.Write "Reason: " & Err.description & "<br>"
Set g_oEracom = Nothing
Response.End
Else
Response.Write "Here are the results for Encrypt function:<br>"
Response.Write "CipherTxt = " & g_sCipherTxt & "<br>"
Response.Write "CipherLen = " & g_lngCipherLen & "<br>"
End If
////////////////////////////////////////////
However, the output parameters cannot be passed out successfully. It seems that the ByRef keyword is the one that's causing the problem.
Is it anything that we have to do in order to pass the parameter out from the function by reference?
Rgds,
hkung
I have an VB Active X dll, namely VBDLL.dll, with the following function declaration :
/////////////////////////////////////
Private Declare Function EncryptOnly Lib "CDLL.dll" _
Alias "_EncryptOnly@28" (ByVal CSN As String, _
ByVal CSNLen As Long, ByVal PlainTxt As String, _
ByVal PlainLen As Long, ByVal IV As String, _
ByVal CipherTxt As String, ByRef CipherLen As Long) As Long
/////////////////////////////////////
All the parameters are input parameters except the last two, which are CipherTxt and CipherLen that are output parameters.
(Notes : CDLL.dll is a C Win32 dll.)
The following function is in the Active X dll :
///////////////////////////////////////////////
Public Function Encrypt(ByVal CSN As String, _
ByVal CSNLen As Long, ByVal PlainTxt As String, _
ByVal PlainLen As Long, ByVal IV As String, _
CipherTxt As String, CipherLen As Long)
Dim CipherTxt1 As String
Dim CipherLen1 As Long
CipherTxt1 = String(2000, vbNullChar)
CipherLen1 = 2000
ReturnValue = EncryptOnly(CSN, CSNLen, PlainTxt, PlainLen, IV, CipherTxt1, CipherLen1)
CipherTxt = CipherTxt1
CipherLen = CipherLen1
End Function
/////////////////////////////////////////////////
When ASP page call the Encrypt function in the Active X dll, it can successfully pass in the input parameter.
The ASP codes snippet is as follows :
///////////////////////////////////////////////
Set g_oEracom = Server.CreateObject("VBDLL.CVBDLL"
g_oEracom.Encrypt g_sCSN, g_lngCSNLen, g_sPlainTxt, g_lngPlainLen, g_sIV, g_sCipherTxt, g_lngCipherLen
If Err.number <> 0 Then
Response.Write "Encrypt function failed!<br>"
Response.Write "Reason: " & Err.description & "<br>"
Set g_oEracom = Nothing
Response.End
Else
Response.Write "Here are the results for Encrypt function:<br>"
Response.Write "CipherTxt = " & g_sCipherTxt & "<br>"
Response.Write "CipherLen = " & g_lngCipherLen & "<br>"
End If
////////////////////////////////////////////
However, the output parameters cannot be passed out successfully. It seems that the ByRef keyword is the one that's causing the problem.
Is it anything that we have to do in order to pass the parameter out from the function by reference?
Rgds,
hkung