-
weird looping problem
Code:
registry.Open(HKEY_CURRENT_USER, _T("Software\\VB and VBA Program Settings\\fbserver\\settings"), FALSE);
registry.Read("total",num);
registry.Open(HKEY_CURRENT_USER, _T("Software\\VB and VBA Program Settings\\fbserver\\titles"), FALSE);
for(int i=1;i<=num;i++){
registry.Read(itoa(i,buffer,10),title);
lst_favs.AddString(title);
}
registry.Close();
when i add to the list box, itll add the last one alot of times, maybe 30 or 40 times. anyone have any idea why?
-
How is your registry.Read function written?
-
i didn't write it, but here it is:
Code:
BOOL CRegisterWIN32::Read(LPCTSTR szKey, LPTSTR &pszValue)
{
BOOL bResult = FALSE;
try
{
if ( StringIN(szKey) )
{
//** The Key exist so proceed
if( pszValue != NULL )
delete pszValue;
//** We re-allocate memory on destination pointer
pszValue = new _TCHAR[_tcslen(m_szTemp) + 1 * sizeof(TCHAR)];
//** Transfert the reading result
_tcscpy(pszValue, m_szTemp);
bResult = TRUE;
}
}
catch(...)
{
bResult = FALSE;
}
return bResult;
}
-
nevermind i fixed it:
Code:
if(!registry.Read(itoa(i,buffer,10),title)){
break;
}
lst_favs.AddString(title);
did that instead