473,398 Members | 2,525 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

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

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
2 1176
> 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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Andy Sutorius via DotNetMonster.com | last post by:
Hi, I have a Sorted List that has 9 key/value pairs. I am trying to take one of the key/value pairs and store the value of that key into a string variable. However, the value that actually gets...
8
by: dwok | last post by:
I have been wondering this for a while now. Suppose I have a class that contains some private member variables. How should I access the variables throughout the class? Should I use properties that...
2
by: John Swan | last post by:
Hello. I cannot seem to find any documentation upon the STL string. I am simply trying to transfer the contents of a std::string to a System::String where I am coming into difficulties. Any...
24
by: Marcus Kwok | last post by:
Hello, I am working on cleaning up some code that I inherited and was wondering if there is anything wrong with my function. I am fairly proficient in standard C++ but I am pretty new to the .NET...
1
by: Vivienne | last post by:
Hi, I am using a c# library in my c++ project. so I have to convert a basic string to System::string to make use of a function that takes System::String as argument. I did it like this: ...
1
by: ayan4u | last post by:
is it possible to send messages from system class such as "edit" to an application local class.... the situation is that i am in system class which is registered(by the system) for a child...
4
by: archu007 | last post by:
hi i'm using the following statement in my application string strTArray = new string; strTArray = (string)(Session); when i run the application its giving the below error {"Unable to cast...
4
by: barnum | last post by:
Hi, I have a std::string which I know is UTF-8 encoded. How can I make a System::String^ from it? I tried UTF8Encoding class, but it wants a Byte array, and I don't know how to get that from a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.