Click here to Skip to main content
16,006,065 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionMySQL with MFC Pin
dcb123456713-Sep-06 4:18
dcb123456713-Sep-06 4:18 
AnswerRe: MySQL with MFC Pin
Chris Losinger13-Sep-06 5:08
professionalChris Losinger13-Sep-06 5:08 
QuestionCString Convert to LPCTSTR Pin
rxgmoral13-Sep-06 3:59
rxgmoral13-Sep-06 3:59 
QuestionRe: CString Convert to LPCTSTR Pin
prasad_som13-Sep-06 4:05
prasad_som13-Sep-06 4:05 
AnswerRe: CString Convert to LPCTSTR Pin
Zac Howland13-Sep-06 4:20
Zac Howland13-Sep-06 4:20 
AnswerRe: CString Convert to LPCTSTR Pin
toxcct13-Sep-06 4:21
toxcct13-Sep-06 4:21 
AnswerRe: CString Convert to LPCTSTR Pin
David Crow13-Sep-06 4:30
David Crow13-Sep-06 4:30 
AnswerRe: CString Convert to LPCTSTR Pin
Steve S13-Sep-06 6:34
Steve S13-Sep-06 6:34 
1. First, you have a CString which is only temporary. When Fun() ends, the CString object will be destructed.
2. As has been pointed out, GetBuffer() isn't needed, since there's a perfectly good cast operator for LPCTSTR.
3. As written, the temporary CString (Rxg) will get locked by GetBuffer(). This will no doubt cause problems when the temporary is destructed, since the CString data is now locked.

To get string data back from the DLL function, you could pass in a destination buffer and size as parameters, and after checking size, you can then fill in the string. To retain the semantics of Fun(), have it return the address of the destination buffer (although the parameter should be LPTSTR, not LPCTSTR).

Steve S
Developer for hire

AnswerRe: CString Convert to LPCTSTR Pin
ThatsAlok13-Sep-06 18:51
ThatsAlok13-Sep-06 18:51 
AnswerRe: CString Convert to LPCTSTR Pin
Hamid_RT14-Sep-06 8:39
Hamid_RT14-Sep-06 8:39 
Question[Message Deleted] Pin
KKumarTG13-Sep-06 3:44
KKumarTG13-Sep-06 3:44 
AnswerRe: Exception in C++ Pin
Cedric Moonen13-Sep-06 3:46
Cedric Moonen13-Sep-06 3:46 
AnswerRe: Exception in C++ Pin
Zac Howland13-Sep-06 4:13
Zac Howland13-Sep-06 4:13 
AnswerRe: [Message Deleted] Pin
ThatsAlok13-Sep-06 18:52
ThatsAlok13-Sep-06 18:52 
AnswerRe: [Message Deleted] Pin
Hamid_RT14-Sep-06 8:39
Hamid_RT14-Sep-06 8:39 
Questionmatlab file (m-file) to c++ Pin
Haoman1713-Sep-06 3:42
Haoman1713-Sep-06 3:42 
AnswerRe: matlab file (m-file) to c++ Pin
Jun Du13-Sep-06 8:15
Jun Du13-Sep-06 8:15 
QuestionShare OpenGL Displaylists in MDI Applications Pin
olaebo13-Sep-06 2:59
olaebo13-Sep-06 2:59 
AnswerRe: Share OpenGL Displaylists in MDI Applications Pin
nadiric13-Sep-06 5:46
nadiric13-Sep-06 5:46 
AnswerRe: Share OpenGL Displaylists in MDI Applications Pin
cmk13-Sep-06 8:07
cmk13-Sep-06 8:07 
QuestionVc++ express edition Pin
Anu_Bala13-Sep-06 2:49
Anu_Bala13-Sep-06 2:49 
AnswerRe: Vc++ express edition Pin
David Crow13-Sep-06 2:59
David Crow13-Sep-06 2:59 
GeneralRe: Vc++ express edition Pin
Anu_Bala13-Sep-06 18:04
Anu_Bala13-Sep-06 18:04 
Questionwindows explorer Pin
radhika2813-Sep-06 2:18
radhika2813-Sep-06 2:18 
AnswerRe: windows explorer Pin
sujtha13-Sep-06 2:22
sujtha13-Sep-06 2:22 

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.