I am receiving this error "run-time error 49" bad DLL calling convention.
I am calling a DLL writen in C. The DLL expects a LONG and then a structure with 4 ints and one char *.
I have declared the function as follows;
Declare Function dllname Lib "api.dll" Alias "_dllname @24" (ByVal val1 As Long, ByVal options As Options) As Integer
I have declared the structure as follows;
var1 As Integer
var2 As Integer
var3 As Integer
var4 As Long
var5 As Integer
With the string data in var4, I convert the UNICODE string to ANSI. To do this, I create an array of byte characters.
The string convert function (StrConv) will do this. To get the pointer to a memory address in VB, I use an undocumented function in VB called
(VarPtr) that returns the memory address of the pointer.
I then set this to the Long variable in the var4 in the structure.
When I call the function in the C DLL, I get the above mentioned error. Any thoughts as to why?