你获取得其实也是c:\\test\\test只不过\在c++里是转义得,所以你看到就是c:\test\test
为什么要赚?

解决方案 »

  1.   

    你知道C里“\“是怎么表示的吗?
    并不是和“A” 啊,“B”啊一样。
    它是个转义字符,“\\“就是一个:“\“
      

  2.   

    char CurrentPath[_MAX_PATH];
    char szdir[_MAX_DIR];
    char szdrive[_MAX_DRIVE];
             GetModuleFileName(NULL,LPTSTR(CurrentPath),_MAX_PATH);
    _splitpath(CurrentPath,szdrive,szdir,NULL,NULL);
    char *temp="history.ini";
    char *temp1;
    temp1=strcat(szdrive,szdir);
             char *Mydir;
    Mydir=strcat(temp1,temp);
    char sztemp[20];
    ZeroMemory(sztemp,20);
    GetPrivateProfileString("test","user1",NULL,sztemp,20,Mydir);
    cout<<sztemp;
    接触输出的是空白
      

  3.   

    但是如果cout<<Mydir;输出的是正常的路径!
      

  4.   

    而且把GetPrivateProfileString("test","user1",NULL,sztemp,20,Mydir);
    这一句改成
    GetPrivateProfileString("test","user1",NULL,sztemp,20,"c:\\test\\test\hostory.ini");
    就可以正常读出INI文件里的内容了