byref strings c++ vb.net

M

marfi95

I'm trying to call a C++ component from my vb.net app. This method has
a prototype of int GetV (char *verData). I've setup a Declare
statement like the following:

Declare Auto Function GetV Lib "myread.dll" Alias "GetV" (ByRef vData
As String) As Integer. BTW, I've also tried ANSI and UNICODE.

I'm assuming this is correct, but when I call it from my VB.Net app, I
get an unhandled exception even though the vb code is within a try
block. I know the DLL returns a string, but I'm unsure how to pass
strings byref to c++ dlls. I'm not sure is the DLL is MFC or not since
it is not my DLL. Not even sure how to tell or if it even matters.

Any help would be appreciated.

Thanks,
Mark
 
M

Mattias Sjögren

Declare Auto Function GetV Lib "myread.dll" Alias "GetV" (ByRef vData
As String) As Integer. BTW, I've also tried ANSI and UNICODE.

The String parameter shoud be passed ByVal, not ByRef.



Mattias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top