Click here to Skip to main content
15,905,420 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Very interesting Question about Compilers Pin
Neville Franks18-Mar-03 10:55
Neville Franks18-Mar-03 10:55 
GeneralRe: Very interesting Question about Compilers Pin
Joel Holdsworth18-Mar-03 11:26
Joel Holdsworth18-Mar-03 11:26 
GeneralRe: Very interesting Question about Compilers Pin
Neville Franks18-Mar-03 12:29
Neville Franks18-Mar-03 12:29 
GeneralON_THREAD_MESSAGE Pin
clintsinger18-Mar-03 9:20
clintsinger18-Mar-03 9:20 
GeneralRe: ON_THREAD_MESSAGE Pin
Dave Bryant18-Mar-03 9:38
Dave Bryant18-Mar-03 9:38 
QuestionWell, when I use cstringVar.GetBuffer() I need to call ReleaseBuffer, but if I (LPTSTR)(LPCTSTR)cstringVar? Pin
Joan M18-Mar-03 9:10
professionalJoan M18-Mar-03 9:10 
AnswerRe: Well, when I use cstringVar.GetBuffer() I need to call ReleaseBuffer, but if I (LPTSTR)(LPCTSTR)cstringVar? Pin
Dave Bryant18-Mar-03 9:33
Dave Bryant18-Mar-03 9:33 
AnswerRe: Well, when I use cstringVar.GetBuffer() I need to call ReleaseBuffer, but if I (LPTSTR)(LPCTSTR)cstringVar? Pin
Tim Smith18-Mar-03 9:34
Tim Smith18-Mar-03 9:34 
First, if Arxiu.Write is not going to modify the string, then it should be declared as a LPCTSTR and not LPTSTR. Then the problem just magically goes away.

However, if you have no control over how Arxiu.Write is defined AND you are 100% sure that it does not modify the buffer, then (LPTSTR)(LPCTSTR) is safe but bad style and risky. The only time I ever use that construct is when I am working with Windows API where some structures are dual purpose and thus can not be defined as const when they are being used in a read-only context. (i.e. SetItem for tree views)

Now, you will need to invoke ReleaseBuffer in method B.

Here is an excellet talk about string classes.

http://www.codeproject.com/string/cppstringguide2.asp?target=getbuffer[^]

(Mike doesn't agree with me on the (LPCTSTR) construct for VERY good reasons. One cut and paste into a situation where the buffer is written to will crash the problem.)

Tim Smith

I'm going to patent thought. I have yet to see any prior art.
GeneralRe: Well, when I use cstringVar.GetBuffer() I need to call ReleaseBuffer, but if I (LPTSTR)(LPCTSTR)cstringVar? Pin
Joan M20-Mar-03 5:05
professionalJoan M20-Mar-03 5:05 
GeneralATL Object Wizard Pin
DuFF18-Mar-03 8:59
DuFF18-Mar-03 8:59 
GeneralCombine multiple images into one Pin
AWebDude18-Mar-03 8:59
AWebDude18-Mar-03 8:59 
GeneralRe: Combine multiple images into one Pin
Maximilien18-Mar-03 9:07
Maximilien18-Mar-03 9:07 
GeneralRe: Combine multiple images into one Pin
AWebDude18-Mar-03 9:34
AWebDude18-Mar-03 9:34 
GeneralRe: Combine multiple images into one Pin
Larry Antram18-Mar-03 10:05
Larry Antram18-Mar-03 10:05 
GeneralSort Pin
Anthony988718-Mar-03 7:16
Anthony988718-Mar-03 7:16 
GeneralRe: Sort Pin
valikac18-Mar-03 8:49
valikac18-Mar-03 8:49 
GeneralRe: Sort Pin
Chris Meech18-Mar-03 8:57
Chris Meech18-Mar-03 8:57 
GeneralHelp! Pin
Dennis L18-Mar-03 6:59
Dennis L18-Mar-03 6:59 
GeneralRe: Help! Pin
AlexO18-Mar-03 7:39
AlexO18-Mar-03 7:39 
GeneralRe: Help! Pin
Anonymous18-Mar-03 9:20
Anonymous18-Mar-03 9:20 
GeneralRe: Help! Pin
AlexO18-Mar-03 10:29
AlexO18-Mar-03 10:29 
GeneralRe: Help! Pin
Anonymous18-Mar-03 9:21
Anonymous18-Mar-03 9:21 
GeneralShell Namespace Pin
Ana Lucia18-Mar-03 6:41
Ana Lucia18-Mar-03 6:41 
Generalchanging an int to a _variant_t Pin
Chris Eatough18-Mar-03 6:20
Chris Eatough18-Mar-03 6:20 
GeneralRe: changing an int to a _variant_t Pin
Ian Darling18-Mar-03 6:35
Ian Darling18-Mar-03 6:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.