Hi guys,
I want to control some USB-measurement device (spectrometer) and they gave me this dll:
specu1a.dll
The manufacturer gave me some VB-Code which is working and the Interop-Decleration looks like this:
Public Declare Ansi Function USB_OpenDevice Lib "specu1a.dll" Alias "USB_OpenDevice" ( _
ByVal ProductID As UShort _
) As Integer
This Code works and the function return a valid Integer representing the DeviceHandle
I am not new to DllImport stuff so I tried the function to open the device like this:
[DllImport("specu1a.dll")]
public static extern int USB_OpenDevice(ushort ProductID);
And? result=-1
even more sofisticated attempts like this:
[DllImport("specu1a.dll", CallingConvention=CallingConvention.StdCall, CharSet=CharSet.Ansi)]
[return:MarshalAs(UnmanagedType.I4)]
public static extern unsafe int USB_OpenDevice([MarshalAs(UnmanagedType.U2)]ushort ProductID);
came out with the same...
WHAT A I DOING WRONG?
There is no error Message from VS2012, I use x86 build settings and this "Marshal.Prelink(Methodinfo USB_OpenDevice)" also gives no error so the dll should be loading correctly.