Menu items missing in shell context menu...
-
I'm trying to show the shell context menu for a file when only having the file name. I got the menu to come up but not all the menu items are showing up - like the ones virus scanners or zip utilities add to all files ("Scan File", "Add to Zip" etc.). Is there anything I'm missing:
typedef HRESULT (WINAPI *lpfnSHBindToParent)(LPCITEMIDLIST pidl, REFIID riid, VOID **ppv, LPCITEMIDLIST *ppidlLast); LRESULT OnContextMenu(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { lpfnSHBindToParent pSHBindToParent = (lpfnSHBindToParent)GetProcAddress(GetModuleHandle(TEXT("SHELL32.DLL")), "SHBindToParent"); if (pSHBindToParent) { LPOLESTR pwszFileName; #ifdef UNICODE pwszFileName = strFullFileName; #else WCHAR wsz[MAX_PATH]; MultiByteToWideChar(CP_ACP, 0, strFullFileName, -1, wsz, ARRAYSIZE(wsz)); pwszFileName = wsz; #endif LPSHELLFOLDER pDesktopFolder; if (SHGetDesktopFolder(&pDesktopFolder) == NOERROR) { LPITEMIDLIST pidl; if (pDesktopFolder->ParseDisplayName(hMainWnd, NULL, pwszFileName, NULL, &pidl, NULL) == S_OK) { LPSHELLFOLDER pParentFolder; LPCITEMIDLIST pidlLast; if (pSHBindToParent(pidl, IID_IShellFolder, (void**)&pParentFolder, &pidlLast) == S_OK) { IContextMenu* picm; if (pParentFolder->GetUIObjectOf(hMainWnd, 1, &pidlLast, IID_IContextMenu, NULL, (void**)&picm) == S_OK) { HMENU hMenuPopup = CreatePopupMenu(); if (hMenuPopup) { if ( SUCCEEDED( picm->QueryContextMenu(hMenuPopup, 0, 1, 0x7fff, CMF_NORMAL) )) { // when menu is shown not all the menu items are there... } DestroyMenu(hMenuPopup); } picm->Release(); } pParentFolder->Release(); } CoTaskMemFree(pidl); } pDesktopFolder->Release(); } } return 0; }
- thanks