how can I get back the whole array after calling an unmanaged pre-net C++ dll

laptop_01

Member
Joined
Feb 6, 2003
Messages
14
Folks;

My VB Net Application is trying to retrieve an int32 array from a C++ dll but for some reason, I only get bac the first element of the array !!

This is my call to the dll (using a call to encapsulate the UI call)
clsCallDLL.dll_call1(intX, strY, intZ, intArray(0))

where intArray is an int32 array of 2 elements

The declaration is as follows:

Imports System.Runtime.InteropServices
Public Class clsCallDLL Declare Sub dll_call1 Lib "MY.DLL" _
(ByRef x As Int32, ByVal y As String, ByVal z As Int32, _
ByRef myArray As Int32)
End Class


Problem is that I am only retrieving intArray(0) back. intArray(1) is not coming back. I pre-set it to -99 before the call and it stays -99 after the call. What can I do to get the whole array back and not just the first element.

Thanks
 
I suggest you look at this file:

FrameworkSDK\Samples\Technologies\Interop\PlatformInvoke\ReadMe.htm

It contains information on how to marshal arrays to win32 dlls like you are trying to do, specifically arrays of integers. There is a sample project included in a subdirectory, doing exactly this.
 
Back
Top