0

If CString to LPCTSTR (const), cast it directly. Am I correct?

If CString to LPTSTR, call GetBuffer() and ReleaseBuffer() between the block that use the LPTSTR variable. Am I correct?

linquize
  • 19,828
  • 10
  • 59
  • 83

1 Answers1

4

Yes, you can get an unmodifiable view of the underlying character array by casting, which calls CString's conversion operator.

And you can get a writable buffer by calling GetBuffer(), and you should call ReleaseBuffer() when you're done writing it, and want to use the CString again.

jwismar
  • 12,164
  • 3
  • 32
  • 44