请教一下GetPrivateProfileInt的问题

lanluosi2010 lanluosi2010 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
代码如下
void CMyINI::SetStrSection(LPCTSTR strSection)
{
m_strSection=strSection;
char strBuff[256];
m_FilePath=(char)GetCurrentDirectory(256,strBuff); //获取当前路径
m_FilePath.Format(_T("%s\\uservar.ini"),strBuff);
}

CString CMyINI::m_strSection=_T("");
CString CMyINI::m_FilePath=_T(".\\uservar.ini");


UINT CMyINI::ReadIntINI(LPCTSTR strSectionKey)
{
UINT m_keyInt=1;
m_keyInt=GetPrivateProfileInt(m_strSection,strSectionKey,89,m_FilePath);
if (0==m_keyInt)
{
AfxMessageBox("why is zero??");
AfxMessageBox(m_FilePath);
}
return m_keyInt;
}


现在的问题很奇怪,就是GetPrivateProfileInt这个有时灵,有时不灵,不管我用相对路径还是绝对路径
而且,函数发生错误之后,照理应该是得到默认值89,但是它返回的却是0,请问到底是哪里出了问题呢,我用的XP SP3系统
uservar.ini文件和程序放在同一个目录。返回0报错的时候,弹出的m_FilePath路径是正确的。
...全文
评论 7
收藏 已收藏
分享
返回顶部
lanluosi2010
VC/MFC 16,551 成员 421,605 内容