
Calling a C++ dll from VB
Hi all
I know this probably isnt the appropriate place to post this type of problem
but it is a really bizarre one and i dont know where to go to.
I reciently built a dll in vc++ it had only one entry function, with 4
parameters
int APIENTRY GetComArg(char* retcode, char *filepath, char *signature, char
*license )
I tested it with a simple main written in c++ and everything works fine.
Im now trying to run this dll from VBScript and a strange thing happens.
my vb code looks thike this
This is all behind a button
Private Sub Command1_Click()
Dim sLocation As String
Dim sSigID As String
Dim sRegText As String
Dim eCode As String
sLocation = "a:\myprog.exe"
sSigID = "%1 %2 %3 %4"
sRegText = "Signature Test"
eCode = "MM"
Call WriteNTSig(eCode, sLocation, sSigID, sRegText)
End Sub
// in the decleration of WriteNTSig
Declare Function GetComArg Lib "C:\My
Projects\NewSigNT\Release\NewSigNT.dll" (ByVal errorcode As String, ByVal
filepath As String, ByVal signature As String, ByVal license As String)
Function WriteNTSig(eCode As String, sLocation As String, sSigID As String,
sRegText As String)
Dim iRetVal As Integer
iRetVal = GetComArg(eCode, sLocation, sSigID, sRegText)
MsgBox "Complete " & iRetVal
End Function
The problem is as this - the parameters when passed to the dll get sqewed!
retcode is null
filepath has the value of retcode "MM"
signature has the value for filepath "a:\myprog.exe"
license has the value for signature "Signature Test"
and the value for license disappears
The error Runtime Error 49 Bad Dll Calling Convention appears but im using
the right number of parameters and the right type(as far as i can see)
All help in this difficult matter will be greatly appreciated
James