|
-
September 1st, 2010, 01:41 AM
#1
Calling C++ DLL from VB
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.
Simple ones like:
void yasdiMasterInitialize( char * cIniFileName, DWORD * pDriverCount)
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.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|