Reading the parameter name which is pArray, it seems that the whole array
should be passed.
Have you tried passing the address of array? Maybe the declaration of API
method is also NOT valid.
Anyways to get the address of a variable, you case
System.Runtime.InteropServices namespace and can use GCHandle class.
Example:
Dim a() As Integer = {5, 6, 4, 10}
Dim gh As GCHandle = System.Runtime.InteropServices.GCHandle.Alloc(a,
GCHandleType.Pinned)
Dim i As IntPtr = gh.AddrOfPinnedObject()
Debug.Print(i.ToInt32()) ' <--- getting address of array
gh.Free()
On Mon, Jan 3, 2011 at 5:52 PM, Jeff Steinkamp (N7YG) <[email protected]
> wrote:
> The reference to parray is an array of 2048 integers that represents FFT
> data. I’m trying to get those from the ActiveX control into my program so I
> can manipulate them for further processing
>
> Jeff K. Steinkamp N7YG
> Tucson, AZ
> SCUD Missile Coordinates:
> N032-13-55.02 W110-55-52.79
> Registered Linux User: 420428
> ------------------------------------------------------
>
> Small white pigeons mysteriously appeared in people's clothing.
>
> *From:* Charles A. Lopez <[email protected]>
> *Sent:* Sunday, January 02, 2011 22:47
> *To:* [email protected]
> *Subject:* Re: [DotNetDevelopment] Marshel array of integers to C++
> ActiveX method
>
> What are you trying to do?
>
> On 1 January 2011 01:41, Jeff Steinkamp (N7YG) <[email protected]> wrote:
>
>> I have an ActiveX library that was built using C++ with the following
>> method:
>> �
>> Public Overridable Function ReadFFT(ByRef pArray As Integer, ByVal wCount
>> As Short) As Short
>> �
>> I can dissemble the Interop files created and the declaration is
>> ReadFFT(int32&, int16)
>> �
>> I assumed you could write the following and it would work:
>> �
>> dim ar(2047) as int32
>> myActiveXLib.ReadFFT(ar(0),arr.length)
>> �
>> But the CLR croaks with some cryptic messages about MDR
>> �
>> �
>> How do you marshal this into the unmanaged ActiveX world?
>> �
>> �
>> Jeff K. Steinkamp N7YG
>> Tucson, AZ
>> SCUD Missile Coordinates:
>> N032-13-55.02 W110-55-52.79
>> Registered Linux User: 420428
>> ------------------------------------------------------
>>
>> Orville Bullitt - Mouth is in gear, brain is in neutral.
>>
>
>
>
> --
> Charles A. Lopez
> [email protected]
>
>
>
>
>