我使用theApp.GetSectionString(lpszSubSection, lpszEntry, lpszDefault)
来从注册表中读取值。BUG:theApp.GetSectionString()不返回默认值
问题是如果注册表中缺少目标条目,它不会返回默认值。
CString str = GetSectionString(_T("Settings"),_T("Gugus"),_T("default 123"));
我也总是检查str
,如果它是一个空字符串,然后手动将其设置为默认值的str
。
这是一个错误或默认行为GetSectionString()
?
CString str = theApp.GetSectionString (_T("Xenax"),_T("MechanicalLimit X-,X+,-Y-,Y+"), "-20999, 4799, 2699, -9999");
if (str.empty()) // <- Needed, :((
{
str = "-20999, 4799, 2699, -9999" ;
}
“CWinAppEx :: GetSectionString()”中存在一个错误。这个bug在VS 2012中修复 –
是的,我正在使用VS2010。 VS2010中有这个问题的解决方法吗? –
您必须更新到VS 2012或更高版本的VS或使用该解决方法。 –