MCPcopy Create free account
hub / github.com/BeneficialCode/WinArk / BuildTree

Method BuildTree

WinArk/View.cpp:349–394  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

347}
348
349HTREEITEM 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
396LRESULT CRegistryManagerView::OnBuildTree(UINT, WPARAM, LPARAM, BOOL&) {
397 InitTree();

Callers

nothing calls this directly

Calls 4

InsertItemMethod · 0.80
OpenMethod · 0.45
CloseMethod · 0.45
DetachMethod · 0.45

Tested by

no test coverage detected