PRB: DeleteUrl() Does Not Delete the Internet Explorer History Folder Entry (327569)
The information in this article applies to:
- Microsoft Internet Explorer (Programming)
This article was previously published under Q327569 SYMPTOMS
After you call the IUrlHistoryStg::DeleteUrl method for a URL, the URL entry still appears in the Internet Explorer History Shell folder.
RESOLUTION
Use the IContextMenu::InvokeCommand method to delete the items. This is similar to manually deleting the item. The disadvantage to this method is that you cannot disable the confirmation dialog box that appears.
The source code that follows demonstrates the resolution by deleting the first, top-level History Shell folder. Typically, this is the oldest day in the history (for example, Tuesday). You can modify the code to delete a more specific item.
// Error checking minimized for clarity.
void DeleteUrlFromHistoryShell()
{
HRESULT hr;
// Call this if needed.
CoInitialize( NULL );
IShellFolder* pDesktopFolder = NULL;
IMalloc* pMalloc = NULL;
hr = ::SHGetMalloc(&pMalloc);
// Get desktop folder.
hr = ::SHGetDesktopFolder(&pDesktopFolder);
// Get the history folder.
ITEMIDLIST* pidlHistoryFolder = NULL;
hr = ::SHGetSpecialFolderLocation(NULL, CSIDL_HISTORY, &pidlHistoryFolder);
// Get the IShellFolder of the history folder.
IShellFolder* pHistoryFolder = NULL;
hr = pDesktopFolder->BindToObject(pidlHistoryFolder, NULL, IID_IShellFolder, (void**)&pHistoryFolder);
// Enumerate the history items.
IEnumIDList* pHistoryEnum = NULL;
hr = pHistoryFolder->EnumObjects(NULL, SHCONTF_FOLDERS | SHCONTF_NONFOLDERS, &pHistoryEnum);
ITEMIDLIST* pidl = NULL;
ULONG fetched = 0;
hr = pHistoryEnum->Next(1, &pidl, &fetched);
if (SUCCEEDED(hr))
{
const ITEMIDLIST* pidl2 = pidl;
// Get the IContextMenu interface.
IContextMenu* pContextMenu = NULL;
hr = pHistoryFolder->GetUIObjectOf(NULL, 1, &pidl2, IID_IContextMenu, NULL, (void**)&pContextMenu);
if (SUCCEEDED(hr))
{
CMINVOKECOMMANDINFO pCommandInfo = { 0 };
pCommandInfo.cbSize = sizeof(CMINVOKECOMMANDINFO);
pCommandInfo.lpVerb = _T("delete");
pCommandInfo.fMask = CMIC_MASK_FLAG_NO_UI; // has no effect
hr = pContextMenu->InvokeCommand(&pCommandInfo);
}
pContextMenu->Release();
}
pHistoryEnum->Release();
pHistoryFolder->Release();
pMalloc->Release();
pDesktopFolder->Release();
}
STATUSThis behavior is by design.REFERENCES
For more information, visit the following Microsoft Developer Network (MSDN) Web sites:
For more information about developing Web-based solutions for Microsoft Internet Explorer, visit the following Microsoft Web sites:
Modification Type: | Major | Last Reviewed: | 4/21/2006 |
---|
Keywords: | kbprb kbURLMon KB327569 kbAudDeveloper |
---|
|