I'm not sure whether this is a VB forum question or a C++ question, but I'll try here first.
I have an API library written in C++ (including source) which compiles to several DLLs. I want to call the functions in the library from VB but I can't get the parameter passing right.
Can be called by:
<DllImport("yasdimaster.dll", CallingConvention:=CallingConvention.Cdecl)> Public Function yasdiMasterInitialize(ByVal IniFile As String, ByRef DriverCount As UInt32) As Integer
End Function
But anything with arrays:
int GetDeviceName( DWORD DevHandle, char * DestBuffer, int len)
I can't seem to get right:
<DllImport("yasdimaster.dll", CallingConvention:=CallingConvention.Cdecl)> Public Function GetDeviceName(ByVal DeviceNumber As UInt32, ByVal DeviceName As String, ByVal Length As Integer) As Integer
End Function
The above example runs but returns nothing. If I change DeviceName to ByRef, I get protected memory errors.
The full library and documentation is available on the internet if anyone would like to download it and I've successfully compiled it with VS2010.
In .net we use a string builder class as input when calling such a C function and the system automatically takes care of things. If that is not possible, is there any way of passing in a raw array from VB?
Last edited by Zaccheus; September 2nd, 2010 at 04:54 AM.
Bookmarks