Home All Groups Group Topic Archive Search About

Returning a string from C++ dll to VB.net

Author
23 Jun 2009 6:58 PM
Ellie
I'm having a lot of trouble with this one so any help would be appreciated.
The C++ dll is just using the standard libraries. I have no trouble getting
numeric values. thanks

Author
23 Jun 2009 8:10 PM
Brian Muth
"Ellie" <ellymay999nospam@nospamnetzero.com> wrote in message
news:uNfJSSD9JHA.5780@TK2MSFTNGP03.phx.gbl...
> I'm having a lot of trouble with this one so any help would be
> appreciated. The C++ dll is just using the standard libraries. I have no
> trouble getting numeric values. thanks

You will need Marshal.PtrToStringAnsi. Google for code examples.
Author
23 Jun 2009 9:58 PM
Giovanni Dicanio
"Ellie" <ellymay999nospam@nospamnetzero.com> ha scritto nel messaggio
news:uNfJSSD9JHA.5780@TK2MSFTNGP03.phx.gbl...
> I'm having a lot of trouble with this one so any help would be
> appreciated. The C++ dll is just using the standard libraries.

Could you please show us the exact prototype of the C++ DLL function?
What do you exactly mean with "the C++ dll is just using the standard
libraries": does it mean that you are using std::wstring at DLL interface?

Instead, if you are using raw TCHAR pointers at DLL interface to return
strings, you could look at PInvoke of GetWindowText API:

http://www.pinvoke.net/default.aspx/user32/GetWindowText.html

(The key idea there is to use the StringBuilder class.)

HTH,
Giovanni