Calling C Function DLL from vb.NET

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi,
I have a problem calling a C dll from inside vb.net by using the DllImport command
when called from C it looks like this:
<span style="font-size:small <span style="font-size:small
<pre class="prettyprint rv = MD_SendReceive(adapter, originatorID, FM_NUMBER_CUSTOM_FM, request, RESERVED, reply, &recvLength, &appState);[/code]



the request and reply are declared as
<span style="font-size:small <span style="font-size:small
MD_Buffer_t request[3], reply[2];
typedef:

<span style="font-size:x-small <span style="font-size:x-small
<pre class="prettyprint typedef struct
{
uint8  pData ;
uint32 length ;
} MD_Buffer_t ;[/code]

how should I transform this into VB.net code

<span style="font-size:x-small My attempt to do this looks like this:

<span style="font-size:x-small <span style="font-size:x-small <br/>

<pre class="prettyprint lang-vb <DllImport("C:SafeNetPCI HSMbinethsm.dll")> Public Shared Function MD_SendReceive(ByVal Operation As UInt32, _
ByVal originatorID As UInt32, _
ByVal FM_NUMBER_CUSTOM_FM As UInt16, _
ByVal buffer() As Request, _
ByVal reserved As UInt32, _
ByVal reply() As Request, _
ByVal recvLength As UInt32, _
ByVal appState As UInt32) As Array()
End Function
Public Structure Request
Public pData As String
Public length As UInt32
End Structure[/code]
but since I dont know C I dont know how to convert it...
Thanks in advance...


View the full article
 
Back
Top