Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27027

VS 2010 Passing char array to a C++ library from a VB application.

$
0
0
Hey folks,

i have a library exporting the following function:
Code:

void SCDocumentString (void *scHandle, uint32 docId, uint32 offset, uint8 *outKey, uint8 *outVal)
Code:

<DllImport("SCLibrary.dll", CallingConvention:=CallingConvention.StdCall)> _
Private Function SCDocumentString(ByVal scHandle As UIntPtr, ByVal docId As UInt32, ByVal offset As UInt32, ByVal outKey As String, ByVal outVal As String) As Long
End Function

i'm able to call the function, but the outKey and outVal are never set. However, when i use my debugger to step into the C++ library, the strcpy's are properly done, and i can see the outKey and outVal buffers being written.

i have tried so many different ways to call the function, i can't seem to find the right one. Basically, when doing this:
Code:

Dim key = Space(64)
Dim val = Space(512)
If (stringCount>0)
    For i As UInt32=0 To stringCount-1
        SCDocumentString(scHandle, docId, i, key, val)
        Console.WriteLine("    {0}: {1}", New String(key), New String(val))
    Next
End If

The output i get is filled with spaces (From the Space(64) and Space(512) assignations), it looks like my buffers never change.

What am i doing wrong?

Thanks,
Pierre.

Viewing all articles
Browse latest Browse all 27027

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>