void Explorerplusplus::HandleAddressBarText(void) { LPITEMIDLIST pidl = NULL; TCHAR szAddressBarTitle[MAX_PATH]; pidl = m_pActiveShellBrowser->QueryCurrentDirectoryIdl(); TCHAR szParsingPath[MAX_PATH]; GetDisplayName(pidl,szParsingPath,SHGDN_FORPARSING); /* If the path is a GUID (i.e. of the form ::{20D04FE0-3AEA-1069-A2D8-08002B30309D}), we'll switch to showing the in folder name. Otherwise, we'll show the full path. Driven by the principle that GUID's should NOT be shown directly to users. */ if(IsPathGUID(szParsingPath)) { GetDisplayName(pidl,szAddressBarTitle,SHGDN_INFOLDER); } else { StringCchCopy(szAddressBarTitle,SIZEOF_ARRAY(szAddressBarTitle), szParsingPath); } SetComboBoxExTitleString(m_hAddressBar,pidl,szAddressBarTitle); CoTaskMemFree(pidl); }
TEST(IsPathGUID, NonGUID) { TCHAR szResourceDirectory[MAX_PATH]; GetTestResourceDirectory(szResourceDirectory, SIZEOF_ARRAY(szResourceDirectory)); BOOL bRet = IsPathGUID(szResourceDirectory); EXPECT_EQ(FALSE, bRet); }
TEST(IsPathGUID, GUID) { BOOL bRet = IsPathGUID(L"::{26EE0668-A00A-44D7-9371-BEB064C98683}"); EXPECT_EQ(TRUE, bRet); }