By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,407 Members | 1,008 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,407 IT Pros & Developers. It's quick & easy.

accessing string buffer posessed by System::String class directly?

P: n/a
Hi,

My managed C++ library frequently takes LPCTSTR from managed exe. Due to the
fact that my library doesn't modify string buffer if its parameter type is
LPCTSTR, it won't be required to copy text data from System::String to
another buffer memory, however, I couldn't find how to let my library access
System::String text buffer directly.

Please reply any answers. Thanks in advance.

Regards,
Hyun-jik Bae
Nov 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
> My managed C++ library frequently takes LPCTSTR from managed exe. Due to
the fact that my library doesn't modify string buffer if its parameter
type is LPCTSTR, it won't be required to copy text data from
System::String to another buffer memory, however, I couldn't find how to
let my library access System::String text buffer directly.


Sounds like you're looking for PtrToStringChars(), defined in vcclr.h.

That said, notice this returns a const Char* (i.e. const wchar_t*), so it
would be always equivalent to LPCWSTR. You'll never be able to fully get it
to work naturally for LPCTSTR because it just won't work if you compile for
ANSI/MBCS (since System::Strings are unicode always)
--
Tomas Restrepo
to****@mvps.org
http://www.winterdom.com/
Nov 17 '05 #2

P: n/a
Hi Bae!
My managed C++ library frequently takes LPCTSTR from managed exe. Due to the
fact that my library doesn't modify string buffer if its parameter type is
LPCTSTR, it won't be required to copy text data from System::String to
another buffer memory, however, I couldn't find how to let my library access
System::String text buffer directly.


See: Convert from System::String* to TCHAR*/CString
http://blog.kalmbachnet.de/?postid=18

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
Nov 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.