|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Handling C++ DLL string pointerI 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)? The string should be passed ByVal. If it's an output parameter,>I have tried passing lptstrSource as String. However, it is always empty. consider using the StringBuilder type instead. Mattias -- Mattias Sjögren [C# MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com Please reply only to the newsgroup. Mattias,
It works perfectly. Thanks a lot. ^_^ alex Show quoteHide quote "Mattias Sjogren" <mattias.dont.want.spam@mvps.org> wrote in message news:eb$I4ulyGHA.3428@TK2MSFTNGP02.phx.gbl... > >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 > > -- > Mattias Sjögren [C# MVP] mattias @ mvps.org > http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com > Please reply only to the newsgroup. |
|||||||||||||||||||||||