Handling C++ DLL string pointer

  • Thread starter Thread starter penguin
  • Start date Start date
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
 
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
 
Back
Top