laptop_01 Posted February 6, 2003 Posted February 6, 2003 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 Quote
*Gurus* divil Posted February 6, 2003 *Gurus* Posted February 6, 2003 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. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
laptop_01 Posted February 6, 2003 Author Posted February 6, 2003 Thanks; I looked where you pointed me and got this part working. Thanks very much Quote
Recommended Posts