Handling C++ DLL string pointer

P

penguin

All,

I have a C++ DLL that has the following function in it.

LONG MYAPI myApi_FunctionName
(
LONG lDSType, /* i Source type */
LPWSTR lptstrSource, /* io Source name */
LONG lDSLength, /* i Length of lptstrSource */
LPCWSTR lpctstrCat, /* i Catalogue */
LPCWSTR lpctstrSubj /* i Subject */
);

I have the following declared in my VB2005 module.

Public Declare Unicode Function myApi_FunctionName Lib "mydll.dll" (ByVal lDSType As Integer, _
ByRef lptstrSource As Integer, _
ByVal lDSLength As Integer, _
ByVal lpctstrCat As String, _
ByVal lpctstrSubj As String) As Integer

If I declare lptstrSource as Integer, I get a numeric value. I believe it is the pointer address. The question is, how do I get the actual "Source name" string (i.e. lptstrSource)?
I have tried passing lptstrSource as String. However, it is always empty.

Thanks,

alex
 
M

Mattias Sjögren

If I declare lptstrSource as Integer, I get a numeric value. I believe it is the pointer address. The question is, how do I get the actual "Source name" string (i.e. lptstrSource)?
I have tried passing lptstrSource as String. However, it is always empty.

The string should be passed ByVal. If it's an output parameter,
consider using the StringBuilder type instead.


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