我写了个配置文件这样读取是对的
CString strServerIp;
CString strIpFileName = "C:\\ip.config";
CString ipInfo, ipstr;
GetPrivateProfileString("ip info", "IP Address", "",ipstr.GetBuffer(100),100, strIpFileName);
ipstr.ReleaseBuffer();
ipInfo += (ipstr + "\r\n");
strServerIp = ipInfo;
可是我把配置文件放在Release下,上面的第二行改成这样的
CString strIpFileName = ".\\Release\\ip.config";就不对了,怎么回事呢??大家告诉我下啊!!
大家的配置文件打包时都放在哪呀?
CString strServerIp;
CString strIpFileName = "C:\\ip.config";
CString ipInfo, ipstr;
GetPrivateProfileString("ip info", "IP Address", "",ipstr.GetBuffer(100),100, strIpFileName);
ipstr.ReleaseBuffer();
ipInfo += (ipstr + "\r\n");
strServerIp = ipInfo;
可是我把配置文件放在Release下,上面的第二行改成这样的
CString strIpFileName = ".\\Release\\ip.config";就不对了,怎么回事呢??大家告诉我下啊!!
大家的配置文件打包时都放在哪呀?
CString strIpFileName = GetApPath() + "config.ini";CString GetApPath()
{
TCHAR exeFullPath[MAX_PATH];
CString strPath;
// GetModuleFileName(NULL,exeFullPath,MAX_PATH);
GetModuleFileName(AfxGetInstanceHandle(),exeFullPath,MAX_PATH);
strPath=(CString)exeFullPath;
int position=strPath.ReverseFind('\\');
strPath=strPath.Left(position+1); return strPath;
}
{
CString strPathName;
GetModuleFileName(NULL,strPathName.GetBuffer(256),256);
strPathName.ReleaseBuffer();
int nPos = strPathName.ReverseFind('\\');
strPathName = strPathName.Left(nPos + 1);
return strPathName;
}