Once you've found the items you want in the Recycle Bin, you may want to perform some operation on them. This brings us back to our old friend, IContextMenu. At this point, you're just snapping two blocks together. You have one block called Retrieving properties from items in the Recycle Bin and you have another block called Invoking verbs on items. For the first block, let's assume you've written a function called WantToRestoreThisItem which studies the properties of a Recycle Bin item and determines whether you want to restore it. I leave this for you to implement, since I don't know what your criteria are. Maybe you want to restore files only if they were deleted from a particular directory. Maybe you want to restore files that were deleted while you were drunk. (This assumes you have some other computer program that tracks when you're drunk.)¹ Whatever. It's your function. For the second block, we have a helper function which should look awfully familiar.void InvokeVerb(IContextMenu *pcm, PCSTR pszVerb)
{
HMENU hmenu = CreatePopupMenu();
if (hmenu) {
HRESULT hr = pcm->QueryContextMenu(hmenu, 0, 1, 0x7FFF, CMF_NORMAL);
if(SUCCEEDED(hr)) {
CMINVOKECOMMANDINFO info = { 0 };
info.cbSize = sizeof(info);
info.lpVerb = pszVerb;
pcm->InvokeCommand(&info);
}
DestroyMenu(hmenu);
}
}
Read more: The Old New Thing
QR:
{
HMENU hmenu = CreatePopupMenu();
if (hmenu) {
HRESULT hr = pcm->QueryContextMenu(hmenu, 0, 1, 0x7FFF, CMF_NORMAL);
if(SUCCEEDED(hr)) {
CMINVOKECOMMANDINFO info = { 0 };
info.cbSize = sizeof(info);
info.lpVerb = pszVerb;
pcm->InvokeCommand(&info);
}
DestroyMenu(hmenu);
}
}
Read more: The Old New Thing
QR:
0 comments:
Post a Comment