I am stuck because I can't access the dll from vb6, I know that the answer is simple:
Here is the VB6 code I am testing:
Here is what I believe is the C code from the source files for mpusbapi.dll:
Public Declare Function MPUSBGetDeviceCount Lib "mpusbapi.dll" Alias "_MPUSBGetDeviceCount" (ByVal pVID_PID As String) As Long
Global count As Long
count = MPUSBGetDeviceCount("vid_04d8&pid_003f" & Null) ''ERROR here with Error 49 Bad DLL calling convention
The DLL routine returns a DWORD which I think is VB6 Long and the argument is PCHAR which I think is a Null terminated string so I added the Null in calling it.
DWORD MPUSBGetDeviceCount(PCHAR pVID_PID)
DWORD count; // Number of USB device with matching VID & PID
count = 0; // Initialization
for(int i = 0; i < MAX_NUM_MPUSB_DEV; i++)
if(MPUSBGetDeviceLink(i,pVID_PID,NULL,NULL,NULL) == MPUSB_SUCCESS)
I've tried it many different ways with no luck-- always ' Error 49 Bad DLL calling convention'.
Have you got any thoughts on this?
I have attached the Dll if you want to quickly try this.