How to pass one dimensional array to VC++ DLL?

meetmak

New member
Joined
Apr 21, 2010
Messages
1
Programming Experience
1-3
Hey,

I have a VC++ DLL, which returns the sum of two long double values, passed as one dimensional array?

could anybody please tell the right syntax to pass array to this dll from vb.net

currently, my code snippet is as follows:
DllClass.vb

VB.NET:
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports System.Runtime.InteropServices
Imports System.Diagnostics
Public Class DllClass
    Private Const dllfilename As String = "D:\vc++_prgs\dll_array\Debug\dll_array.dll"

    <DllImport(dllfilename, EntryPoint:="read", CharSet:=CharSet.Ansi)> _
    Public Shared Function read(ByVal c() As Double) As IntPtr
    End Function
End Class

Form1.vb
VB.NET:
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim arr(2) As Double
        arr(0) = Convert.ToDouble(TextBox1.Text)
        arr(1) = Convert.ToDouble(TextBox2.Text)
      
        Dim res As Double = DllClass.read(arr)
        TextBox3.Text = res.ToString
    End Sub
End Class


Is the above procedure correct? I am not getting the desired results!!
Thanks a lot
 
Back
Top