+static VOID
+UpdateAddress(HTREEITEM hItem, HKEY hRootKey, LPCWSTR pszPath)
+{
+ LPCWSTR keyPath, rootName;
+ LPWSTR fullPath;
+
+ if (pszPath == NULL)
+ keyPath = GetItemPath(g_pChildWnd->hTreeWnd, hItem, &hRootKey);
+ else
+ keyPath = pszPath;
+
+ if (keyPath)
+ {
+ RefreshListView(g_pChildWnd->hListWnd, hRootKey, keyPath);
+ rootName = get_root_key_name(hRootKey);
+ fullPath = HeapAlloc(GetProcessHeap(), 0, (wcslen(rootName) + 1 + wcslen(keyPath) + 1) * sizeof(WCHAR));
+ if (fullPath)
+ {
+ /* set (correct) the address bar text */
+ if (keyPath[0] != L'\0')
+ swprintf(fullPath, L"%s\\%s", rootName, keyPath);
+ else
+ fullPath = wcscpy(fullPath, rootName);
+ SendMessageW(hStatusBar, SB_SETTEXTW, 0, (LPARAM)fullPath);
+ SendMessageW(g_pChildWnd->hAddressBarWnd, WM_SETTEXT, 0, (LPARAM)fullPath);
+ HeapFree(GetProcessHeap(), 0, fullPath);
+ /* disable hive manipulation items temporarily (enable only if necessary) */
+ EnableMenuItem(GetSubMenu(hMenuFrame,0), ID_REGISTRY_LOADHIVE, MF_BYCOMMAND | MF_GRAYED);
+ EnableMenuItem(GetSubMenu(hMenuFrame,0), ID_REGISTRY_UNLOADHIVE, MF_BYCOMMAND | MF_GRAYED);
+ /* compare the strings to see if we should enable/disable the "Load Hive" menus accordingly */
+ if (!(wcsicmp(rootName, L"HKEY_LOCAL_MACHINE") &&
+ wcsicmp(rootName, L"HKEY_USERS")))
+ {
+ /*
+ * enable the unload menu item if at the root, otherwise
+ * enable the load menu item if there is no slash in
+ * keyPath (ie. immediate child selected)
+ */
+ if(keyPath[0] == L'\0')
+ EnableMenuItem(GetSubMenu(hMenuFrame,0), ID_REGISTRY_LOADHIVE, MF_BYCOMMAND | MF_ENABLED);
+ else if(!wcschr(keyPath, L'\\'))
+ EnableMenuItem(GetSubMenu(hMenuFrame,0), ID_REGISTRY_UNLOADHIVE, MF_BYCOMMAND | MF_ENABLED);
+ }
+ }
+ }
+}
+