在使用下边函数的时候
GetPrivateProfileStrin("trunkcode","trunk","default",ch,10,"seatdata.ini")
如果seatdata.ini参数不写全路径名的时候,这个文件应该存在什么位置呀,我把它放在debug目录下和源文件目录下,都读不出数据,只有写全路径名的时候就可以得出正确结果,那如果像上边那咱写法,这个文件应该放在什么位置呢?

解决方案 »

  1.   

    Windows2000之后就不支持那些ini文件的API了,要用注册表
      

  2.   

    http://www.caisong.com/read.php/368.htm
      

  3.   

    默认是":\WINDOWS\system32"
    一楼的不要误导群众
      

  4.   

    lpFileName 
    [in] Pointer to a null-terminated string that specifies the name of the initialization file. If this parameter does not contain a full path to the file, the system searches for the file in the Windows directory. 
    楼上说的对,看上边的的解释!
      

  5.   

    >...那如果像上边那咱写法,这个文件应该放在什么位置呢?
    ----------------------
    如果此 ini 文件是你的配置文件, 则最好放在你的可执行文件所在的目录. 再通过 GetModuleFileName 分析出绝对路径, 然后调用 GetPrivateProfileString
      

  6.   

    逍遥兄是正解,现在都讲究绿色,谁还把配置放到系统目录?如果我的程序TD2000.exe在D:\Test\目录下,下面这个
    CString sPath;
    int nPos;
    GetModuleFileName(NULL,sPath.GetBufferSetLength(MAX_PATH+1),MAX_PATH);
    sPath.ReleaseBuffer();
    nPos=sPath.ReverseFind('\\');
    sPath=sPath.Left(nPos);
    CString lpszFile=sPath+"\\TD2000.exe";lpszFile就是D:\Test\TD2000.exe