| 347 | } |
| 348 | |
| 349 | HTREEITEM CRegistryManagerView::BuildTree(HTREEITEM hRoot, HKEY hKey, PCWSTR name) { |
| 350 | if (name) { |
| 351 | hRoot = m_Tree.InsertItem(name, 3, 2, hRoot, TVI_LAST); |
| 352 | auto path = GetFullNodePath(hRoot); |
| 353 | if (Registry::IsHiveKey(path)) { |
| 354 | SetNodeData(hRoot, GetNodeData(hRoot) | NodeType::Hive); |
| 355 | } |
| 356 | auto subkeys = Registry::GetSubKeyCount(hKey); |
| 357 | if (subkeys) { |
| 358 | m_Tree.InsertItem(L"\\\\", hRoot, TVI_LAST); |
| 359 | } |
| 360 | } |
| 361 | else { |
| 362 | CRegKey key(hKey); |
| 363 | Registry::EnumSubKeys(key, [&](auto name, const auto& ft) { |
| 364 | auto hItem = m_Tree.InsertItem(name, 3, 2, hRoot, TVI_LAST); |
| 365 | SetNodeData(hItem, NodeType::Key); |
| 366 | CRegKey subKey; |
| 367 | auto error = subKey.Open(hKey, name, KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS); |
| 368 | if (error == ERROR_SUCCESS) { |
| 369 | DWORD subkeys = Registry::GetSubKeyCount(subKey); |
| 370 | if (subkeys) |
| 371 | m_Tree.InsertItem(L"\\\\", hItem, TVI_LAST); |
| 372 | subKey.Close(); |
| 373 | CString linkPath; |
| 374 | if (Registry::IsKeyLink(key, name, linkPath)) { |
| 375 | // m_Tree.SetItemImage(hItem, 4, 4); |
| 376 | } |
| 377 | } |
| 378 | |
| 379 | else if (error == ERROR_ACCESS_DENIED) { |
| 380 | SetNodeData(hItem, GetNodeData(hItem) | NodeType::AccessDenied); |
| 381 | } |
| 382 | auto path = GetFullNodePath(hItem); |
| 383 | if (Registry::IsHiveKey(path)) { |
| 384 | SetNodeData(hItem, GetNodeData(hItem) | NodeType::Hive); |
| 385 | } |
| 386 | return true; |
| 387 | }); |
| 388 | |
| 389 | m_Tree.SortChildren(hRoot); |
| 390 | key.Detach(); |
| 391 | } |
| 392 | |
| 393 | return hRoot; |
| 394 | } |
| 395 | |
| 396 | LRESULT CRegistryManagerView::OnBuildTree(UINT, WPARAM, LPARAM, BOOL&) { |
| 397 | InitTree(); |
nothing calls this directly
no test coverage detected