这是代码中的一部分,为的是将获取的当前路径文件按当前日期保存并提示保存成功窗口
          #define DEF_BUF_SIZE 2048
         // 取得当前目录路径
WCHAR szFilePath[DEF_BUF_SIZE] = {0} ;
GetCurrentDirectoryW( DEF_BUF_SIZE, szFilePath ) ;

         //关键是这里提示保存到路径,应该显示完整路径,但经调试msg中只保存了szFilePath数组的第一个元素C
CString msg ;
msg.Format ( "%s", szFilePath ) ;//这里改成"%ls"或szFilePath[]或szFilePath[DEF_BUF_SIZE]都不行
MessageBox ( 0, msg, "保存到路径:", 0 ) ;请帮忙分析下,谢!

解决方案 »

  1.   

    CString msg = szFilePath;
      

  2.   

    WCHAR szFilePath[DEF_BUF_SIZE] = {0} ;
     GetCurrentDirectoryW( DEF_BUF_SIZE, szFilePath ) ;
     那就把这两句改了char szFilePath[DEF_BUF_SIZE] = {0} ;
     GetCurrentDirectory( DEF_BUF_SIZE, szFilePath ) ;
     
      

  3.   

    msg.Format("%ws",szFilePath);%s 是格式化char字符
    %ws 格式化wchar宽字符
      

  4.   

    回5楼 msg.Format("%ws",szFilePath);     %s 是格式化char字符
          %ws 格式化wchar宽字符调试有误,只能显示到C:\windows
      

  5.   

    是不是DEF_BUF_SIZE太小了?TCHAR szFilePath[MAX_PATH + 1] = {0} ;
    GetCurrentDirectory( MAX_PATH, szFilePath ) ;
      

  6.   


            TCHAR szPath[MAX_PATH]={0};
    GetCurrentDirectory(MAX_PATH,szPath);
    CString str=szPath;
    MessageBox(str);楼主再试下