Some question about CString,Unicode,and TCHAR *

J

Jason .Y

Hi~I'm planning to make a smiple program to upload file,but I've
traped by a strange problem,here is a chip of my program:
===========================================
LPCTSTR lpszMyFilePath =COptions::StoragePath+_T("\\test\\")+pWData-
cFileName;

LPCTSTR lpszPeerFilePath = pWData->cFileName;

UINT nMyTaskID = 0;

nMyTaskID = WRMCC_RequestUploadFile (/*_T("\\´æ´¢¿¨\\test\
\20080618.dat")*/lpszMyFilePath,lpszPeerFilePath, FTNOTIFY_Callback );

==============
When I was using _T("\\´æ´¢¿¨\\test\\20080618.dat") as LParm,the program
work successfully.but when I use lpszMyFilePath,which i defined myself
above,the server said "File not exist"

P.S.
COptions::StoragePath is a instance of CString

cFileName is a name of TCHAR[ ] array

and the type of upload function is:
UINT WRMCC_RequestUploadFile ( LPCTSTR lpszMyFilePath, LPCTSTR
lpszPeerFilePath=NULL, FUNC_FTNOTIFY_Callback
Proc_FTNOTIFY_Callback=NULL, BOOL bForceRetransmit=FALSE );
 
I

Ian Collins

Jason .Y wrote:

[lots of windows stuff]

Try a windows group, this isn't standard C++.
 
C

cooleaf

LPCTSTR is only a pointer which point to the temp string,
COptions::StoragePath+_T("\\test\\")+pWData-cFileName; will construct
a temp CString ,but after that it will be destroyed, and the pointer
will point to a invalid memory.


by the way, please do not post Chinese charator in your question, here
is a international mailist, so many people can not read in Chinese.



Hi~I'm planning to make a smiple program to upload file,but I've
traped by a strange problem,here is a chip of my program:
===========================================
LPCTSTR lpszMyFilePath =COptions::StoragePath+_T("\\test\\")+pWData-
cFileName;

LPCTSTR lpszPeerFilePath = pWData->cFileName;

UINT nMyTaskID = 0;

nMyTaskID = WRMCC_RequestUploadFile (/*_T("\\´æ´¢¿¨\\test\
\20080618.dat")*/lpszMyFilePath,lpszPeerFilePath, FTNOTIFY_Callback );

==============
When I was using _T("\\´æ´¢¿¨\\test\\20080618.dat") as LParm,the program
work successfully.but when I use lpszMyFilePath,which i defined myself
above,the server said "File not exist"

P.S.
COptions::StoragePath is a instance of CString

cFileName is a name of TCHAR[ ] array

and the type of upload function is:
UINT WRMCC_RequestUploadFile ( LPCTSTR lpszMyFilePath, LPCTSTR
lpszPeerFilePath=NULL, FUNC_FTNOTIFY_Callback
Proc_FTNOTIFY_Callback=NULL, BOOL bForceRetransmit=FALSE );
 
J

Jason .Y

LPCTSTR is only a pointer which point to the temp string,
COptions::StoragePath+_T("\\test\\")+pWData-cFileName; will construct
a temp CString ,but after that it will be destroyed, and the pointer
will point to a invalid memory.

by the way, please do not post Chinese charator in your question, here
is a international mailist, so many people can not read in Chinese.

Hi~I'm planning to make a smiple program to upload file,but I've
traped by a strange problem,here is a chip of my program:
===========================================
LPCTSTR lpszMyFilePath =COptions::StoragePath+_T("\\test\\")+pWData-

LPCTSTR lpszPeerFilePath = pWData->cFileName;
UINT nMyTaskID = 0;
nMyTaskID = WRMCC_RequestUploadFile (/*_T("\\´æ´¢¿¨\\test\
\20080618.dat")*/lpszMyFilePath,lpszPeerFilePath, FTNOTIFY_Callback );
==============
When I was using _T("\\´æ´¢¿¨\\test\\20080618.dat") as LParm,the program
work successfully.but when I use lpszMyFilePath,which i defined myself
above,the server said "File not exist"
P.S.
COptions::StoragePath is a instance of CString
cFileName is a name of TCHAR[ ] array
and the type of upload function is:
UINT WRMCC_RequestUploadFile ( LPCTSTR lpszMyFilePath, LPCTSTR
lpszPeerFilePath=NULL, FUNC_FTNOTIFY_Callback
Proc_FTNOTIFY_Callback=NULL, BOOL bForceRetransmit=FALSE );- Hide quoted text -

- Show quoted text -

I'm sorry for my ruleless post,and thank you very much for your
assistance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top