Some question about CString,Unicode,and TCHAR *

Discussion in 'C++' started by Jason .Y, Jul 31, 2008.

  1. Jason .Y

    Jason .Y Guest

    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 );
    Jason .Y, Jul 31, 2008
    #1
    1. Advertising

  2. Jason .Y

    Ian Collins Guest

    Jason .Y wrote:

    [lots of windows stuff]

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

    --
    Ian Collins.
    Ian Collins, Jul 31, 2008
    #2
    1. Advertising

  3. Jason .Y

    cooleaf Guest

    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.



    On Jul 31, 11:16 am, "Jason .Y" <> wrote:
    > 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 );
    cooleaf, Jul 31, 2008
    #3
  4. Jason .Y

    Jason .Y Guest

    On Jul 31, 1:05 pm, cooleaf <> wrote:
    > 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.
    >
    > On Jul 31, 11:16 am, "Jason .Y" <> wrote:
    >
    >
    >
    > > 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 );- Hide quoted text -

    >
    > - Show quoted text -


    I'm sorry for my ruleless post,and thank you very much for your
    assistance.
    Jason .Y, Jul 31, 2008
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    7
    Views:
    1,242
    MaSTeR
    Dec 14, 2004
  2. Bobby
    Replies:
    0
    Views:
    387
    Bobby
    Dec 14, 2004
  3. Markus Hämmerli
    Replies:
    6
    Views:
    7,745
    Peter van Merkerk
    Sep 4, 2003
  4. sorty
    Replies:
    4
    Views:
    20,693
    Rolf Magnus
    Nov 25, 2003
  5. Anitha Adusumilli

    Wide Characters and tchar

    Anitha Adusumilli, Jan 6, 2005, in forum: C Programming
    Replies:
    1
    Views:
    381
    Derrick Coetzee
    Jan 6, 2005
Loading...

Share This Page