Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

  • *Gurus*
Posted

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.

MVP, Visual Developer - .NET

 

Now you see why evil will always triumph - because good is dumb.

 

My free .NET Windows Forms Controls and Articles

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...