HX_RESULT CWinRegKey::DeleteSubKey(const char* szName) { if(!m_bOpen) { return HXR_UNEXPECTED; } HX_RESULT pnrRes = HXR_FAIL; CWinRegKey wrkExpired; CWinRegKey wrkSub; wrkExpired.SetRootKey(m_hkThis); wrkExpired.SetRelativePath(szName); wrkExpired.SetDesiredAccess(KEY_ENUMERATE_SUB_KEYS|KEY_CREATE_SUB_KEY); if (SUCCEEDED(pnrRes = wrkExpired.Open())) { wrkExpired.ResetKeyEnumerator(); while(wrkExpired.GetNextKey(wrkSub)) { wrkExpired.DeleteSubKey(wrkSub.GetRelativePath()); wrkExpired.ResetKeyEnumerator(); } wrkExpired.Close(); pnrRes = HRESULT_FROM_WIN32(RegDeleteKey(m_hkThis, OS_STRING(szName))); } return pnrRes; }
HXBOOL CWinRegKey::GetNextKey(CWinRegKey& rwrkNext) { if(!m_bOpen) { return FALSE; } char szName[128]; /* Flawfinder: ignore */ UINT32 ulSizeName=128; char szClass[128]; /* Flawfinder: ignore */ UINT32 ulSizeClass=128; FILETIME ftLastWrite; if ( RegEnumKeyEx ( m_hkThis, m_dwKeyEnumPos, OS_STRING2(szName, ulSizeName), &ulSizeName, NULL, OS_STRING2(szClass, ulSizeClass), &ulSizeClass, &ftLastWrite ) == ERROR_SUCCESS ) { ++m_dwKeyEnumPos; rwrkNext.SetRootKey(m_hkThis); rwrkNext.SetRelativePath(szName); rwrkNext.SetDesiredAccess(m_rsAccess); return TRUE; } return FALSE; }