ReactOS  0.4.15-dev-2534-geba00d1
CDefaultContextMenu Class Reference
Inheritance diagram for CDefaultContextMenu:
Collaboration diagram for CDefaultContextMenu:

Public Member Functions

 CDefaultContextMenu ()
 
 ~CDefaultContextMenu ()
 
HRESULT WINAPI Initialize (const DEFCONTEXTMENU *pdcm, LPFNDFMCALLBACK lpfn)
 
virtual HRESULT WINAPI QueryContextMenu (HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags)
 
virtual HRESULT WINAPI InvokeCommand (LPCMINVOKECOMMANDINFO lpcmi)
 
virtual HRESULT WINAPI GetCommandString (UINT_PTR idCommand, UINT uFlags, UINT *lpReserved, LPSTR lpszName, UINT uMaxNameLen)
 
virtual HRESULT WINAPI HandleMenuMsg (UINT uMsg, WPARAM wParam, LPARAM lParam)
 
virtual HRESULT WINAPI HandleMenuMsg2 (UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *plResult)
 
virtual HRESULT STDMETHODCALLTYPE SetSite (IUnknown *pUnkSite)
 
virtual HRESULT STDMETHODCALLTYPE GetSite (REFIID riid, void **ppvSite)
 
- Public Member Functions inherited from ATL::CComObjectRootEx< CComMultiThreadModelNoCS >
 ~CComObjectRootEx ()
 
ULONG InternalAddRef ()
 
ULONG InternalRelease ()
 
void Lock ()
 
void Unlock ()
 
HRESULT _AtlInitialConstruct ()
 
- Public Member Functions inherited from ATL::CComObjectRootBase
 CComObjectRootBase ()
 
 ~CComObjectRootBase ()
 
void SetVoid (void *)
 
HRESULT _AtlFinalConstruct ()
 
HRESULT FinalConstruct ()
 
void InternalFinalConstructAddRef ()
 
void InternalFinalConstructRelease ()
 
void FinalRelease ()
 
- Public Member Functions inherited from IUnknown
HRESULT QueryInterface ([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
 
ULONG AddRef ()
 
ULONG Release ()
 
- Public Member Functions inherited from IObjectWithSite
HRESULT GetSite ([in] REFIID riid, [out, iid_is(riid)] PVOID *ppvSite)
 

Private Member Functions

HRESULT _DoCallback (UINT uMsg, WPARAM wParam, LPVOID lParam)
 
void AddStaticEntry (const HKEY hkeyClass, const WCHAR *szVerb)
 
void AddStaticEntriesForKey (HKEY hKey)
 
BOOL IsShellExtensionAlreadyLoaded (const CLSID *pclsid)
 
HRESULT LoadDynamicContextMenuHandler (HKEY hKey, const CLSID *pclsid)
 
BOOL EnumerateDynamicContextHandlerForKey (HKEY hRootKey)
 
UINT AddShellExtensionsToMenu (HMENU hMenu, UINT *pIndexMenu, UINT idCmdFirst, UINT idCmdLast)
 
UINT AddStaticContextMenusToMenu (HMENU hMenu, UINT *IndexMenu, UINT iIdCmdFirst, UINT iIdCmdLast)
 
HRESULT DoPaste (LPCMINVOKECOMMANDINFO lpcmi, BOOL bLink)
 
HRESULT DoOpenOrExplore (LPCMINVOKECOMMANDINFO lpcmi)
 
HRESULT DoCreateLink (LPCMINVOKECOMMANDINFO lpcmi)
 
HRESULT DoDelete (LPCMINVOKECOMMANDINFO lpcmi)
 
HRESULT DoCopyOrCut (LPCMINVOKECOMMANDINFO lpcmi, BOOL bCopy)
 
HRESULT DoRename (LPCMINVOKECOMMANDINFO lpcmi)
 
HRESULT DoProperties (LPCMINVOKECOMMANDINFO lpcmi)
 
HRESULT DoUndo (LPCMINVOKECOMMANDINFO lpcmi)
 
HRESULT DoCreateNewFolder (LPCMINVOKECOMMANDINFO lpici)
 
HRESULT DoCopyToMoveToFolder (LPCMINVOKECOMMANDINFO lpici, BOOL bCopy)
 
HRESULT InvokeShellExt (LPCMINVOKECOMMANDINFO lpcmi)
 
HRESULT InvokeRegVerb (LPCMINVOKECOMMANDINFO lpcmi)
 
DWORD BrowserFlagsFromVerb (LPCMINVOKECOMMANDINFO lpcmi, PStaticShellEntry pEntry)
 
HRESULT TryToBrowse (LPCMINVOKECOMMANDINFO lpcmi, LPCITEMIDLIST pidl, DWORD wFlags)
 
HRESULT InvokePidl (LPCMINVOKECOMMANDINFO lpcmi, LPCITEMIDLIST pidl, PStaticShellEntry pEntry)
 
PDynamicShellEntry GetDynamicEntry (UINT idCmd)
 
BOOL MapVerbToCmdId (PVOID Verb, PUINT idCmd, BOOL IsUnicode)
 

Private Attributes

CComPtr< IUnknownm_site
 
CComPtr< IShellFolderm_psf
 
CComPtr< IContextMenuCBm_pmcb
 
LPFNDFMCALLBACK m_pfnmcb
 
UINT m_cidl
 
PCUITEMID_CHILD_ARRAY m_apidl
 
CComPtr< IDataObjectm_pDataObj
 
HKEYm_aKeys
 
UINT m_cKeys
 
PIDLIST_ABSOLUTE m_pidlFolder
 
DWORD m_bGroupPolicyActive
 
PDynamicShellEntry m_pDynamicEntries
 
UINT m_iIdSHEFirst
 
UINT m_iIdSHELast
 
PStaticShellEntry m_pStaticEntries
 
UINT m_iIdSCMFirst
 
UINT m_iIdSCMLast
 
UINT m_iIdCBFirst
 
UINT m_iIdCBLast
 
UINT m_iIdDfltFirst
 
UINT m_iIdDfltLast
 

Additional Inherited Members

- Public Types inherited from IContextMenu3
typedef IContextMenu3LPCONTEXTMENU3
 
- Public Types inherited from IContextMenu2
typedef IContextMenu2LPCONTEXTMENU2
 
- Public Types inherited from IContextMenu
typedef struct IContextMenu::tagCMINVOKECOMMANDINFO CMINVOKECOMMANDINFO
 
typedef struct IContextMenu::tagCMINVOKECOMMANDINFOLPCMINVOKECOMMANDINFO
 
typedef struct IContextMenu::tagCMInvokeCommandInfoEx CMINVOKECOMMANDINFOEX
 
typedef struct IContextMenu::tagCMInvokeCommandInfoExLPCMINVOKECOMMANDINFOEX
 
- Public Types inherited from IUnknown
typedef IUnknownLPUNKNOWN
 
- Public Types inherited from IObjectWithSite
typedef IObjectWithSiteLPOBJECTWITHSITE
 
- Static Public Member Functions inherited from ATL::CComObjectRootBase
static void WINAPI ObjectMain (bool)
 
static const struct _ATL_CATMAP_ENTRYGetCategoryMap ()
 
static HRESULT WINAPI InternalQueryInterface (void *pThis, const _ATL_INTMAP_ENTRY *pEntries, REFIID iid, void **ppvObject)
 
- Public Attributes inherited from ATL::CComObjectRootBase
LONG m_dwRef
 
- Public Attributes inherited from IContextMenu
CMIC_MASK_NOZONECHECKS typedef IContextMenuLPCONTEXTMENU
 
- Static Public Attributes inherited from IContextMenu
static CMDSTR_VIEWDETAILSW(const WCHAR []) const WCHAR CMDSTR_NEWFOLDERW [] = {'N','e','w','F','o','l','d','e','r',0}
 
static const WCHAR CMDSTR_VIEWLISTW [] = {'V','i','e','w','L','i','s','t',0}
 
static const WCHAR CMDSTR_VIEWDETAILSW [] = {'V','i','e','w','D','e','t','a','i','l','s',0}
 

Detailed Description

Definition at line 55 of file CDefaultContextMenu.cpp.

Constructor & Destructor Documentation

◆ CDefaultContextMenu()

CDefaultContextMenu::CDefaultContextMenu ( )

Definition at line 137 of file CDefaultContextMenu.cpp.

137  :
138  m_psf(NULL),
139  m_pmcb(NULL),
140  m_pfnmcb(NULL),
141  m_cidl(0),
142  m_apidl(NULL),
143  m_pDataObj(NULL),
144  m_aKeys(NULL),
145  m_cKeys(NULL),
149  m_iIdSHEFirst(0),
150  m_iIdSHELast(0),
152  m_iIdSCMFirst(0),
153  m_iIdSCMLast(0),
154  m_iIdCBFirst(0),
155  m_iIdCBLast(0),
156  m_iIdDfltFirst(0),
157  m_iIdDfltLast(0)
158 
159 {
160 }
PIDLIST_ABSOLUTE m_pidlFolder
CComPtr< IShellFolder > m_psf
CComPtr< IDataObject > m_pDataObj
PDynamicShellEntry m_pDynamicEntries
#define NULL
Definition: types.h:112
CComPtr< IContextMenuCB > m_pmcb
PStaticShellEntry m_pStaticEntries
PCUITEMID_CHILD_ARRAY m_apidl

◆ ~CDefaultContextMenu()

CDefaultContextMenu::~CDefaultContextMenu ( )

Definition at line 162 of file CDefaultContextMenu.cpp.

163 {
164  /* Free dynamic shell extension entries */
165  PDynamicShellEntry pDynamicEntry = m_pDynamicEntries, pNextDynamic;
166  while (pDynamicEntry)
167  {
168  pNextDynamic = pDynamicEntry->pNext;
169  pDynamicEntry->pCM->Release();
170  HeapFree(GetProcessHeap(), 0, pDynamicEntry);
171  pDynamicEntry = pNextDynamic;
172  }
173 
174  /* Free static shell extension entries */
175  PStaticShellEntry pStaticEntry = m_pStaticEntries, pNextStatic;
176  while (pStaticEntry)
177  {
178  pNextStatic = pStaticEntry->pNext;
179  HeapFree(GetProcessHeap(), 0, pStaticEntry->szVerb);
180  HeapFree(GetProcessHeap(), 0, pStaticEntry);
181  pStaticEntry = pNextStatic;
182  }
183 
184  for (UINT i = 0; i < m_cKeys; i++)
187 
188  if (m_pidlFolder)
190  _ILFreeaPidl(const_cast<PITEMID_CHILD *>(m_apidl), m_cidl);
191 }
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
PIDLIST_ABSOLUTE m_pidlFolder
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
ULONG Release()
#define GetProcessHeap()
Definition: compat.h:595
struct _DynamicShellEntry_ * pNext
void _ILFreeaPidl(LPITEMIDLIST *apidl, UINT cidl)
Definition: pidl.c:2635
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
PDynamicShellEntry m_pDynamicEntries
struct _StaticShellEntry_ * pNext
unsigned int UINT
Definition: ndis.h:50
PStaticShellEntry m_pStaticEntries
#define HeapFree(x, y, z)
Definition: compat.h:594
PCUITEMID_CHILD_ARRAY m_apidl

Member Function Documentation

◆ _DoCallback()

HRESULT CDefaultContextMenu::_DoCallback ( UINT  uMsg,
WPARAM  wParam,
LPVOID  lParam 
)
private

Definition at line 240 of file CDefaultContextMenu.cpp.

241 {
242  if (m_pmcb)
243  {
244  return m_pmcb->CallBack(m_psf, NULL, m_pDataObj, uMsg, wParam, (LPARAM)lParam);
245  }
246  else if(m_pfnmcb)
247  {
248  return m_pfnmcb(m_psf, NULL, m_pDataObj, uMsg, wParam, (LPARAM)lParam);
249  }
250 
251  return E_FAIL;
252 }
#define E_FAIL
Definition: ddrawi.h:102
WPARAM wParam
Definition: combotst.c:138
LONG_PTR LPARAM
Definition: windef.h:208
CComPtr< IShellFolder > m_psf
CComPtr< IDataObject > m_pDataObj
#define NULL
Definition: types.h:112
CComPtr< IContextMenuCB > m_pmcb
LPARAM lParam
Definition: combotst.c:139

Referenced by DoProperties(), InvokeCommand(), and QueryContextMenu().

◆ AddShellExtensionsToMenu()

UINT CDefaultContextMenu::AddShellExtensionsToMenu ( HMENU  hMenu,
UINT pIndexMenu,
UINT  idCmdFirst,
UINT  idCmdLast 
)
private

Definition at line 476 of file CDefaultContextMenu.cpp.

477 {
478  UINT cIds = 0;
479 
480  if (!m_pDynamicEntries)
481  return cIds;
482 
484  do
485  {
486  HRESULT hr = pEntry->pCM->QueryContextMenu(hMenu, *pIndexMenu, idCmdFirst + cIds, idCmdLast, CMF_NORMAL);
487  if (SUCCEEDED(hr))
488  {
489  pEntry->iIdCmdFirst = cIds;
490  pEntry->NumIds = LOWORD(hr);
491  (*pIndexMenu) += pEntry->NumIds;
492 
493  cIds += pEntry->NumIds;
494  if(idCmdFirst + cIds >= idCmdLast)
495  break;
496  }
497  TRACE("pEntry %p hr %x contextmenu %p cmdfirst %x num ids %x\n", pEntry, hr, pEntry->pCM, pEntry->iIdCmdFirst, pEntry->NumIds);
498  pEntry = pEntry->pNext;
499  } while (pEntry);
500 
501  return cIds;
502 }
HRESULT hr
Definition: shlfolder.c:183
if SUCCEEDED(hr)
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:79
PDynamicShellEntry m_pDynamicEntries
unsigned int UINT
Definition: ndis.h:50
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
#define LOWORD(l)
Definition: pedump.c:82

Referenced by QueryContextMenu().

◆ AddStaticContextMenusToMenu()

UINT CDefaultContextMenu::AddStaticContextMenusToMenu ( HMENU  hMenu,
UINT IndexMenu,
UINT  iIdCmdFirst,
UINT  iIdCmdLast 
)
private

Definition at line 505 of file CDefaultContextMenu.cpp.

510 {
511  MENUITEMINFOW mii;
512  UINT idResource;
513  WCHAR wszVerb[40];
514  UINT fState;
515  UINT cIds = 0;
516 
517  mii.cbSize = sizeof(mii);
519  mii.fType = MFT_STRING;
520  mii.dwTypeData = NULL;
521 
523 
524  while (pEntry)
525  {
526  fState = MFS_ENABLED;
527  mii.dwTypeData = NULL;
528 
529  /* set first entry as default */
530  if (pEntry == m_pStaticEntries)
531  fState |= MFS_DEFAULT;
532 
533  if (!wcsicmp(pEntry->szVerb, L"open"))
534  {
535  /* override default when open verb is found */
536  fState |= MFS_DEFAULT;
537  idResource = IDS_OPEN_VERB;
538  }
539  else if (!wcsicmp(pEntry->szVerb, L"explore"))
540  idResource = IDS_EXPLORE_VERB;
541  else if (!wcsicmp(pEntry->szVerb, L"runas"))
542  idResource = IDS_RUNAS_VERB;
543  else if (!wcsicmp(pEntry->szVerb, L"edit"))
544  idResource = IDS_EDIT_VERB;
545  else if (!wcsicmp(pEntry->szVerb, L"find"))
546  idResource = IDS_FIND_VERB;
547  else if (!wcsicmp(pEntry->szVerb, L"print"))
548  idResource = IDS_PRINT_VERB;
549  else if (!wcsicmp(pEntry->szVerb, L"printto"))
550  {
551  pEntry = pEntry->pNext;
552  continue;
553  }
554  else
555  idResource = 0;
556 
557  /* By default use verb for menu item name */
558  mii.dwTypeData = pEntry->szVerb;
559 
560  WCHAR wszKey[256];
561  HRESULT hr;
562  hr = StringCbPrintfW(wszKey, sizeof(wszKey), L"shell\\%s", pEntry->szVerb);
563  if (FAILED_UNEXPECTEDLY(hr))
564  {
565  pEntry = pEntry->pNext;
566  continue;
567  }
568 
569  BOOL Extended = FALSE;
570  HKEY hkVerb;
571  if (idResource > 0)
572  {
573  if (LoadStringW(shell32_hInstance, idResource, wszVerb, _countof(wszVerb)))
574  mii.dwTypeData = wszVerb; /* use translated verb */
575  else
576  ERR("Failed to load string\n");
577 
578  LONG res = RegOpenKeyW(pEntry->hkClass, wszKey, &hkVerb);
579  if (res == ERROR_SUCCESS)
580  {
581  res = RegQueryValueExW(hkVerb, L"Extended", NULL, NULL, NULL, NULL);
582  Extended = (res == ERROR_SUCCESS);
583 
584  RegCloseKey(hkVerb);
585  }
586  }
587  else
588  {
589  LONG res = RegOpenKeyW(pEntry->hkClass, wszKey, &hkVerb);
590  if (res == ERROR_SUCCESS)
591  {
592  DWORD cbVerb = sizeof(wszVerb);
593  res = RegLoadMUIStringW(hkVerb, NULL, wszVerb, cbVerb, NULL, 0, NULL);
594  if (res == ERROR_SUCCESS)
595  {
596  /* use description for the menu entry */
597  mii.dwTypeData = wszVerb;
598  }
599 
600  res = RegQueryValueExW(hkVerb, L"Extended", NULL, NULL, NULL, NULL);
601  Extended = (res == ERROR_SUCCESS);
602 
603  RegCloseKey(hkVerb);
604  }
605  }
606 
607  if (!Extended || GetAsyncKeyState(VK_SHIFT) < 0)
608  {
609  mii.cch = wcslen(mii.dwTypeData);
610  mii.fState = fState;
611  mii.wID = iIdCmdFirst + cIds;
612  InsertMenuItemW(hMenu, *pIndexMenu, TRUE, &mii);
613  (*pIndexMenu)++;
614  cIds++;
615  }
616 
617  pEntry = pEntry->pNext;
618 
619  if (mii.wID >= iIdCmdLast)
620  break;
621  }
622 
623  return cIds;
624 }
#define MFT_STRING
Definition: winuser.h:741
#define IDS_FIND_VERB
Definition: shresdef.h:213
#define ERROR_SUCCESS
Definition: deptool.c:10
HRESULT hr
Definition: shlfolder.c:183
#define TRUE
Definition: types.h:120
LPWSTR dwTypeData
Definition: winuser.h:3244
#define IDS_OPEN_VERB
Definition: shresdef.h:209
#define MFS_DEFAULT
Definition: winuser.h:743
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define IDS_RUNAS_VERB
Definition: shresdef.h:211
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define MFS_ENABLED
Definition: winuser.h:745
#define FALSE
Definition: types.h:117
#define IDS_EXPLORE_VERB
Definition: shresdef.h:210
#define MIIM_STATE
Definition: winuser.h:716
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3296
#define VK_SHIFT
Definition: winuser.h:2177
#define IDS_PRINT_VERB
Definition: shresdef.h:214
STRSAFEAPI StringCbPrintfW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:557
#define MIIM_ID
Definition: winuser.h:717
#define IDS_EDIT_VERB
Definition: shresdef.h:212
LONG RegLoadMUIStringW(IN HKEY hKey, IN LPCWSTR pszValue OPTIONAL, OUT LPWSTR pszOutBuf, IN DWORD cbOutBuf, OUT LPDWORD pcbData OPTIONAL, IN DWORD Flags, IN LPCWSTR pszDirectory OPTIONAL)
Definition: muireg.c:53
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
#define _countof(array)
Definition: sndvol32.h:68
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
unsigned long DWORD
Definition: ntddk_ex.h:95
#define wcsicmp
Definition: compat.h:15
static const WCHAR L[]
Definition: oid.c:1250
#define MIIM_TYPE
Definition: winuser.h:720
SHORT WINAPI GetAsyncKeyState(_In_ int)
#define ERR(fmt,...)
Definition: debug.h:110
#define shell32_hInstance
BOOL WINAPI InsertMenuItemW(_In_ HMENU, _In_ UINT, _In_ BOOL, _In_ LPCMENUITEMINFOW)
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
GLuint res
Definition: glext.h:9613
#define MIIM_DATA
Definition: winuser.h:721
PStaticShellEntry m_pStaticEntries
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484

Referenced by QueryContextMenu().

◆ AddStaticEntriesForKey()

void CDefaultContextMenu::AddStaticEntriesForKey ( HKEY  hKey)
private

Definition at line 292 of file CDefaultContextMenu.cpp.

293 {
294  WCHAR wszName[40];
295  DWORD cchName, dwIndex = 0;
296  HKEY hShellKey;
297 
298  LRESULT lres = RegOpenKeyExW(hKey, L"shell", 0, KEY_READ, &hShellKey);
299  if (lres != STATUS_SUCCESS)
300  return;
301 
302  while(TRUE)
303  {
304  cchName = _countof(wszName);
305  if (RegEnumKeyExW(hShellKey, dwIndex++, wszName, &cchName, NULL, NULL, NULL, NULL) != ERROR_SUCCESS)
306  break;
307 
308  AddStaticEntry(hKey, wszName);
309  }
310 
311  RegCloseKey(hShellKey);
312 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
#define TRUE
Definition: types.h:120
_In_ PSID _Out_writes_to_opt_ cchName LPSTR _Inout_ LPDWORD cchName
Definition: winbase.h:2745
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
void AddStaticEntry(const HKEY hkeyClass, const WCHAR *szVerb)
FxAutoRegKey hKey
#define NULL
Definition: types.h:112
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
LONG WINAPI RegEnumKeyExW(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
Definition: reg.c:2527
#define STATUS_SUCCESS
Definition: shellext.h:65
LONG_PTR LRESULT
Definition: windef.h:209

Referenced by QueryContextMenu().

◆ AddStaticEntry()

void CDefaultContextMenu::AddStaticEntry ( const HKEY  hkeyClass,
const WCHAR szVerb 
)
private

Definition at line 254 of file CDefaultContextMenu.cpp.

255 {
257  while(pEntry)
258  {
259  if (!wcsicmp(pEntry->szVerb, szVerb))
260  {
261  /* entry already exists */
262  return;
263  }
264  pLastEntry = pEntry;
265  pEntry = pEntry->pNext;
266  }
267 
268  TRACE("adding verb %s\n", debugstr_w(szVerb));
269 
271  if (pEntry)
272  {
273  pEntry->pNext = NULL;
274  pEntry->szVerb = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, (wcslen(szVerb) + 1) * sizeof(WCHAR));
275  if (pEntry->szVerb)
276  wcscpy(pEntry->szVerb, szVerb);
277  pEntry->hkClass = hkeyClass;
278  }
279 
280  if (!wcsicmp(szVerb, L"open"))
281  {
282  /* open verb is always inserted in front */
283  pEntry->pNext = m_pStaticEntries;
285  }
286  else if (pLastEntry)
287  pLastEntry->pNext = pEntry;
288  else
290 }
struct _StaticShellEntry_ StaticShellEntry
#define debugstr_w
Definition: kernel32.h:32
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define wcsicmp
Definition: compat.h:15
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
#define NULL
Definition: types.h:112
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
WCHAR * LPWSTR
Definition: xmlstorage.h:184
PStaticShellEntry m_pStaticEntries
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484

Referenced by AddStaticEntriesForKey().

◆ BrowserFlagsFromVerb()

DWORD CDefaultContextMenu::BrowserFlagsFromVerb ( LPCMINVOKECOMMANDINFO  lpcmi,
PStaticShellEntry  pEntry 
)
private

Definition at line 1071 of file CDefaultContextMenu.cpp.

1072 {
1074  HWND hwndTree;
1075  LPCWSTR FlagsName;
1076  WCHAR wszKey[256];
1077  HRESULT hr;
1078  DWORD wFlags;
1079  DWORD cbVerb;
1080 
1081  if (!m_site)
1082  return 0;
1083 
1084  /* Get a pointer to the shell browser */
1086  if (FAILED_UNEXPECTEDLY(hr))
1087  return 0;
1088 
1089  /* See if we are in Explore or Browse mode. If the browser's tree is present, we are in Explore mode.*/
1090  if (SUCCEEDED(psb->GetControlWindow(FCW_TREE, &hwndTree)) && hwndTree)
1091  FlagsName = L"ExplorerFlags";
1092  else
1093  FlagsName = L"BrowserFlags";
1094 
1095  /* Try to get the flag from the verb */
1096  hr = StringCbPrintfW(wszKey, sizeof(wszKey), L"shell\\%s", pEntry->szVerb);
1097  if (FAILED_UNEXPECTEDLY(hr))
1098  return 0;
1099 
1100  cbVerb = sizeof(wFlags);
1101  if (RegGetValueW(pEntry->hkClass, wszKey, FlagsName, RRF_RT_REG_DWORD, NULL, &wFlags, &cbVerb) == ERROR_SUCCESS)
1102  {
1103  return wFlags;
1104  }
1105 
1106  return 0;
1107 }
LSTATUS WINAPI RegGetValueW(HKEY hKey, LPCWSTR pszSubKey, LPCWSTR pszValue, DWORD dwFlags, LPDWORD pdwType, PVOID pvData, LPDWORD pcbData)
Definition: reg.c:1965
#define ERROR_SUCCESS
Definition: deptool.c:10
HRESULT hr
Definition: shlfolder.c:183
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define IID_PPV_ARG(Itype, ppType)
HRESULT WINAPI IUnknown_QueryService(IUnknown *, REFGUID, REFIID, LPVOID *)
Definition: ordinal.c:1494
if SUCCEEDED(hr)
STRSAFEAPI StringCbPrintfW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:557
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
CComPtr< IUnknown > m_site
_In_ DWORD _Out_ _In_ WORD wFlags
Definition: wincon.h:531
#define SID_IShellBrowser
#define NULL
Definition: types.h:112
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
#define RRF_RT_REG_DWORD
Definition: driver.c:578

Referenced by InvokeRegVerb().

◆ DoCopyOrCut()

HRESULT CDefaultContextMenu::DoCopyOrCut ( LPCMINVOKECOMMANDINFO  lpcmi,
BOOL  bCopy 
)
private

Definition at line 841 of file CDefaultContextMenu.cpp.

842 {
843  if (!m_cidl || !m_pDataObj)
844  return E_FAIL;
845 
846  FORMATETC formatetc;
848  STGMEDIUM medium = {0};
849  medium.tymed = TYMED_HGLOBAL;
850  medium.hGlobal = GlobalAlloc(GHND, sizeof(DWORD));
851  DWORD* pdwFlag = (DWORD*)GlobalLock(medium.hGlobal);
852  if (pdwFlag)
853  *pdwFlag = bCopy ? DROPEFFECT_COPY : DROPEFFECT_MOVE;
854  GlobalUnlock(medium.hGlobal);
855  m_pDataObj->SetData(&formatetc, &medium, TRUE);
856 
858  if (FAILED_UNEXPECTEDLY(hr))
859  return hr;
860 
861  return S_OK;
862 }
HRESULT WINAPI OleSetClipboard(IDataObject *data)
Definition: clipboard.c:2199
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
#define CFSTR_PREFERREDDROPEFFECT
Definition: shlobj.h:487
HRESULT hr
Definition: shlfolder.c:183
#define InitFormatEtc(fe, cf, med)
Definition: editor.h:32
#define TRUE
Definition: types.h:120
UINT WINAPI RegisterClipboardFormatW(_In_ LPCWSTR)
#define E_FAIL
Definition: ddrawi.h:102
#define GHND
Definition: winbase.h:294
LONG HRESULT
Definition: typedefs.h:79
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
unsigned long DWORD
Definition: ntddk_ex.h:95
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
#define S_OK
Definition: intsafe.h:51
CComPtr< IDataObject > m_pDataObj
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190

Referenced by InvokeCommand().

◆ DoCopyToMoveToFolder()

HRESULT CDefaultContextMenu::DoCopyToMoveToFolder ( LPCMINVOKECOMMANDINFO  lpici,
BOOL  bCopy 
)
private

Definition at line 907 of file CDefaultContextMenu.cpp.

908 {
909  HRESULT hr = E_FAIL;
910  if (!m_pDataObj)
911  {
912  ERR("m_pDataObj is NULL\n");
913  return hr;
914  }
915 
916  CComPtr<IContextMenu> pContextMenu;
917  if (bCopy)
918  hr = SHCoCreateInstance(NULL, &CLSID_CopyToMenu, NULL,
919  IID_PPV_ARG(IContextMenu, &pContextMenu));
920  else
921  hr = SHCoCreateInstance(NULL, &CLSID_MoveToMenu, NULL,
922  IID_PPV_ARG(IContextMenu, &pContextMenu));
923  if (FAILED_UNEXPECTEDLY(hr))
924  return hr;
925 
927  hr = pContextMenu->QueryInterface(IID_PPV_ARG(IShellExtInit, &pInit));
928  if (FAILED_UNEXPECTEDLY(hr))
929  return hr;
930 
931  hr = pInit->Initialize(m_pidlFolder, m_pDataObj, NULL);
932  if (FAILED_UNEXPECTEDLY(hr))
933  return hr;
934 
935  if (bCopy)
936  lpici->lpVerb = "copyto";
937  else
938  lpici->lpVerb = "moveto";
939 
940  return pContextMenu->InvokeCommand(lpici);
941 }
HRESULT hr
Definition: shlfolder.c:183
PIDLIST_ABSOLUTE m_pidlFolder
#define IID_PPV_ARG(Itype, ppType)
#define E_FAIL
Definition: ddrawi.h:102
HRESULT WINAPI SHCoCreateInstance(LPCWSTR aclsid, const CLSID *clsid, LPUNKNOWN pUnkOuter, REFIID refiid, LPVOID *ppv)
Definition: shellole.c:105
LONG HRESULT
Definition: typedefs.h:79
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
#define ERR(fmt,...)
Definition: debug.h:110
PWDFDEVICE_INIT pInit
CComPtr< IDataObject > m_pDataObj
#define NULL
Definition: types.h:112

Referenced by InvokeCommand().

◆ DoCreateLink()

HRESULT CDefaultContextMenu::DoCreateLink ( LPCMINVOKECOMMANDINFO  lpcmi)
private

Definition at line 811 of file CDefaultContextMenu.cpp.

812 {
813  if (!m_cidl || !m_pDataObj)
814  return E_FAIL;
815 
817  HRESULT hr = m_psf->CreateViewObject(NULL, IID_PPV_ARG(IDropTarget, &pDT));
818  if (FAILED_UNEXPECTEDLY(hr))
819  return hr;
820 
822 
823  return S_OK;
824 }
#define MK_SHIFT
Definition: winuser.h:2344
HRESULT hr
Definition: shlfolder.c:183
#define IID_PPV_ARG(Itype, ppType)
#define E_FAIL
Definition: ddrawi.h:102
LONG HRESULT
Definition: typedefs.h:79
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
CComPtr< IShellFolder > m_psf
#define S_OK
Definition: intsafe.h:51
CComPtr< IDataObject > m_pDataObj
#define NULL
Definition: types.h:112
#define MK_CONTROL
Definition: winuser.h:2345
BOOL WINAPI SHSimulateDrop(IDropTarget *pDrop, IDataObject *pDataObj, DWORD grfKeyState, PPOINTL lpPt, DWORD *pdwEffect)
Definition: ordinal.c:1821

Referenced by InvokeCommand().

◆ DoCreateNewFolder()

HRESULT CDefaultContextMenu::DoCreateNewFolder ( LPCMINVOKECOMMANDINFO  lpici)
private

Definition at line 945 of file CDefaultContextMenu.cpp.

947 {
948  WCHAR wszPath[MAX_PATH];
949  WCHAR wszName[MAX_PATH];
950  WCHAR wszNewFolder[25];
951  HRESULT hr;
952 
953  /* Get folder path */
955  if (FAILED_UNEXPECTEDLY(hr))
956  return hr;
957 
958  if (!LoadStringW(shell32_hInstance, IDS_NEWFOLDER, wszNewFolder, _countof(wszNewFolder)))
959  return E_FAIL;
960 
961  /* Create the name of the new directory */
962  if (!PathYetAnotherMakeUniqueName(wszName, wszPath, NULL, wszNewFolder))
963  return E_FAIL;
964 
965  /* Create the new directory and show the appropriate dialog in case of error */
966  if (SHCreateDirectory(lpici->hwnd, wszName) != ERROR_SUCCESS)
967  return E_FAIL;
968 
969  /* Show and select the new item in the def view */
970  LPITEMIDLIST pidl;
971  PITEMID_CHILD pidlNewItem;
973 
974  /* Notify the view object about the new item */
976 
977  if (!m_site)
978  return S_OK;
979 
980  /* Get a pointer to the shell view */
982  if (FAILED_UNEXPECTEDLY(hr))
983  return S_OK;
984 
985  /* Attempt to get the pidl of the new item */
986  hr = SHILCreateFromPathW(wszName, &pidl, NULL);
987  if (FAILED_UNEXPECTEDLY(hr))
988  return hr;
989 
990  pidlNewItem = ILFindLastID(pidl);
991 
992  hr = psv->SelectItem(pidlNewItem, SVSI_DESELECTOTHERS | SVSI_EDIT | SVSI_ENSUREVISIBLE |
993  SVSI_FOCUSED | SVSI_SELECT);
994  if (FAILED_UNEXPECTEDLY(hr))
995  return hr;
996 
997  SHFree(pidl);
998 
999  return S_OK;
1000 }
#define SHCNE_MKDIR
Definition: shlobj.h:1732
#define IDS_NEWFOLDER
#define ERROR_SUCCESS
Definition: deptool.c:10
HRESULT hr
Definition: shlfolder.c:183
BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath)
Definition: pidl.c:1294
PIDLIST_ABSOLUTE m_pidlFolder
#define SID_IFolderView
#define IID_PPV_ARG(Itype, ppType)
#define E_FAIL
Definition: ddrawi.h:102
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
HRESULT WINAPI IUnknown_QueryService(IUnknown *, REFGUID, REFIID, LPVOID *)
Definition: ordinal.c:1494
LPITEMIDLIST WINAPI ILFindLastID(LPCITEMIDLIST pidl)
Definition: pidl.c:189
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
#define _countof(array)
Definition: sndvol32.h:68
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
#define MAX_PATH
Definition: compat.h:34
EXTERN_C void WINAPI SHChangeNotify(LONG wEventId, UINT uFlags, LPCVOID dwItem1, LPCVOID dwItem2)
CComPtr< IUnknown > m_site
#define SHCNF_PATHW
Definition: shlobj.h:1764
int WINAPI SHCreateDirectory(HWND hWnd, LPCWSTR path)
Definition: shlfileop.cpp:788
#define S_OK
Definition: intsafe.h:51
#define shell32_hInstance
#define NULL
Definition: types.h:112
HRESULT WINAPI SHILCreateFromPathW(LPCWSTR path, LPITEMIDLIST *ppidl, DWORD *attributes)
Definition: pidl.c:392
void WINAPI SHFree(LPVOID pv)
Definition: shellole.c:331
CONST void * LPCVOID
Definition: windef.h:191
BOOL WINAPI PathYetAnotherMakeUniqueName(LPWSTR buffer, LPCWSTR path, LPCWSTR shortname, LPCWSTR longname)
Definition: shellpath.c:368
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41

Referenced by InvokeCommand().

◆ DoDelete()

HRESULT CDefaultContextMenu::DoDelete ( LPCMINVOKECOMMANDINFO  lpcmi)
private

Definition at line 826 of file CDefaultContextMenu.cpp.

827 {
828  if (!m_cidl || !m_pDataObj)
829  return E_FAIL;
830 
833  if (FAILED_UNEXPECTEDLY(hr))
834  return hr;
835 
836  SHSimulateDrop(pDT, m_pDataObj, 0, NULL, NULL);
837 
838  return S_OK;
839 }
HRESULT hr
Definition: shlfolder.c:183
#define IID_PPV_ARG(Itype, ppType)
#define E_FAIL
Definition: ddrawi.h:102
LONG HRESULT
Definition: typedefs.h:79
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
HRESULT CRecyclerDropTarget_CreateInstance(REFIID riid, LPVOID *ppvOut)
#define S_OK
Definition: intsafe.h:51
CComPtr< IDataObject > m_pDataObj
#define NULL
Definition: types.h:112
BOOL WINAPI SHSimulateDrop(IDropTarget *pDrop, IDataObject *pDataObj, DWORD grfKeyState, PPOINTL lpPt, DWORD *pdwEffect)
Definition: ordinal.c:1821

Referenced by InvokeCommand().

◆ DoOpenOrExplore()

HRESULT CDefaultContextMenu::DoOpenOrExplore ( LPCMINVOKECOMMANDINFO  lpcmi)
private

Definition at line 805 of file CDefaultContextMenu.cpp.

806 {
808  return E_FAIL;
809 }
#define E_FAIL
Definition: ddrawi.h:102
#define UNIMPLEMENTED
Definition: debug.h:115

Referenced by InvokeCommand().

◆ DoPaste()

HRESULT CDefaultContextMenu::DoPaste ( LPCMINVOKECOMMANDINFO  lpcmi,
BOOL  bLink 
)
private

Definition at line 753 of file CDefaultContextMenu.cpp.

754 {
755  HRESULT hr;
756 
758  hr = OleGetClipboard(&pda);
759  if (FAILED_UNEXPECTEDLY(hr))
760  return hr;
761 
762  FORMATETC formatetc2;
763  STGMEDIUM medium2;
765 
766  DWORD dwKey= 0;
767 
768  if (SUCCEEDED(pda->GetData(&formatetc2, &medium2)))
769  {
770  DWORD * pdwFlag = (DWORD*)GlobalLock(medium2.hGlobal);
771  if (pdwFlag)
772  {
773  if (*pdwFlag == DROPEFFECT_COPY)
774  dwKey = MK_CONTROL;
775  else
776  dwKey = MK_SHIFT;
777  }
778  else {
779  ERR("No drop effect obtained");
780  }
781  GlobalUnlock(medium2.hGlobal);
782  }
783 
784  if (bLink)
785  {
786  dwKey = MK_CONTROL|MK_SHIFT;
787  }
788 
789  CComPtr<IDropTarget> pdrop;
790  if (m_cidl)
791  hr = m_psf->GetUIObjectOf(NULL, 1, &m_apidl[0], IID_NULL_PPV_ARG(IDropTarget, &pdrop));
792  else
793  hr = m_psf->CreateViewObject(NULL, IID_PPV_ARG(IDropTarget, &pdrop));
794 
795  if (FAILED_UNEXPECTEDLY(hr))
796  return hr;
797 
798  SHSimulateDrop(pdrop, pda, dwKey, NULL, NULL);
799 
800  TRACE("CP result %x\n", hr);
801  return S_OK;
802 }
#define MK_SHIFT
Definition: winuser.h:2344
#define CFSTR_PREFERREDDROPEFFECT
Definition: shlobj.h:487
HRESULT hr
Definition: shlfolder.c:183
#define InitFormatEtc(fe, cf, med)
Definition: editor.h:32
UINT WINAPI RegisterClipboardFormatW(_In_ LPCWSTR)
#define IID_PPV_ARG(Itype, ppType)
HRESULT WINAPI OleGetClipboard(IDataObject **obj)
Definition: clipboard.c:2249
if SUCCEEDED(hr)
#define IID_NULL_PPV_ARG(Itype, ppType)
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:79
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
unsigned long DWORD
Definition: ntddk_ex.h:95
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
CComPtr< IShellFolder > m_psf
#define ERR(fmt,...)
Definition: debug.h:110
#define S_OK
Definition: intsafe.h:51
#define NULL
Definition: types.h:112
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
#define MK_CONTROL
Definition: winuser.h:2345
PCUITEMID_CHILD_ARRAY m_apidl
BOOL WINAPI SHSimulateDrop(IDropTarget *pDrop, IDataObject *pDataObj, DWORD grfKeyState, PPOINTL lpPt, DWORD *pdwEffect)
Definition: ordinal.c:1821

Referenced by InvokeCommand().

◆ DoProperties()

HRESULT CDefaultContextMenu::DoProperties ( LPCMINVOKECOMMANDINFO  lpcmi)
private

Definition at line 891 of file CDefaultContextMenu.cpp.

893 {
895 
896  return S_OK;
897 }
#define DFM_INVOKECOMMAND
Definition: precomp.h:45
#define DFM_CMD_PROPERTIES
Definition: shlobj.h:2429
#define S_OK
Definition: intsafe.h:51
#define NULL
Definition: types.h:112
HRESULT _DoCallback(UINT uMsg, WPARAM wParam, LPVOID lParam)

Referenced by InvokeCommand().

◆ DoRename()

HRESULT CDefaultContextMenu::DoRename ( LPCMINVOKECOMMANDINFO  lpcmi)
private

Definition at line 864 of file CDefaultContextMenu.cpp.

865 {
867  HRESULT hr;
868 
869  if (!m_site || !m_cidl)
870  return E_FAIL;
871 
872  /* Get a pointer to the shell browser */
874  if (FAILED_UNEXPECTEDLY(hr))
875  return hr;
876 
877  CComPtr<IShellView> lpSV;
878  hr = psb->QueryActiveShellView(&lpSV);
879  if (FAILED_UNEXPECTEDLY(hr))
880  return hr;
881 
882  SVSIF selFlags = SVSI_DESELECTOTHERS | SVSI_EDIT | SVSI_ENSUREVISIBLE | SVSI_FOCUSED | SVSI_SELECT;
883  hr = lpSV->SelectItem(m_apidl[0], selFlags);
884  if (FAILED_UNEXPECTEDLY(hr))
885  return hr;
886 
887  return S_OK;
888 }
HRESULT hr
Definition: shlfolder.c:183
#define IID_PPV_ARG(Itype, ppType)
#define E_FAIL
Definition: ddrawi.h:102
HRESULT WINAPI IUnknown_QueryService(IUnknown *, REFGUID, REFIID, LPVOID *)
Definition: ordinal.c:1494
LONG HRESULT
Definition: typedefs.h:79
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
CComPtr< IUnknown > m_site
#define S_OK
Definition: intsafe.h:51
#define SID_IShellBrowser
PCUITEMID_CHILD_ARRAY m_apidl

Referenced by InvokeCommand().

◆ DoUndo()

HRESULT CDefaultContextMenu::DoUndo ( LPCMINVOKECOMMANDINFO  lpcmi)
private

Definition at line 900 of file CDefaultContextMenu.cpp.

901 {
902  ERR("TODO: Undo");
903  return E_NOTIMPL;
904 }
#define ERR(fmt,...)
Definition: debug.h:110
#define E_NOTIMPL
Definition: ddrawi.h:99

Referenced by InvokeCommand().

◆ EnumerateDynamicContextHandlerForKey()

BOOL CDefaultContextMenu::EnumerateDynamicContextHandlerForKey ( HKEY  hRootKey)
private

Definition at line 412 of file CDefaultContextMenu.cpp.

413 {
414  WCHAR wszName[MAX_PATH], wszBuf[MAX_PATH], *pwszClsid;
415  DWORD cchName;
416  HRESULT hr;
417  HKEY hKey;
418 
419  if (RegOpenKeyExW(hRootKey, L"shellex\\ContextMenuHandlers", 0, KEY_READ, &hKey) != ERROR_SUCCESS)
420  {
421  TRACE("RegOpenKeyExW failed\n");
422  return FALSE;
423  }
424 
425  DWORD dwIndex = 0;
426  while (TRUE)
427  {
428  cchName = _countof(wszName);
429  if (RegEnumKeyExW(hKey, dwIndex++, wszName, &cchName, NULL, NULL, NULL, NULL) != ERROR_SUCCESS)
430  break;
431 
432  /* Key name or key value is CLSID */
433  CLSID clsid;
434  hr = CLSIDFromString(wszName, &clsid);
435  if (hr == S_OK)
436  pwszClsid = wszName;
437  else
438  {
439  DWORD cchBuf = _countof(wszBuf);
440  if (RegGetValueW(hKey, wszName, NULL, RRF_RT_REG_SZ, NULL, wszBuf, &cchBuf) == ERROR_SUCCESS)
441  hr = CLSIDFromString(wszBuf, &clsid);
442  pwszClsid = wszBuf;
443  }
444 
445  if (FAILED(hr))
446  {
447  ERR("CLSIDFromString failed for clsid %S hr 0x%x\n", pwszClsid, hr);
448  continue;
449  }
450 
452  {
454  L"Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved",
455  pwszClsid,
457  NULL,
458  NULL,
459  NULL) != ERROR_SUCCESS)
460  {
461  ERR("Shell extension %s not approved!\n", pwszClsid);
462  continue;
463  }
464  }
465 
467  if (FAILED(hr))
468  WARN("Failed to get context menu entires from shell extension! clsid: %S\n", pwszClsid);
469  }
470 
471  RegCloseKey(hKey);
472  return TRUE;
473 }
LSTATUS WINAPI RegGetValueW(HKEY hKey, LPCWSTR pszSubKey, LPCWSTR pszValue, DWORD dwFlags, LPDWORD pdwType, PVOID pvData, LPDWORD pcbData)
Definition: reg.c:1965
#define ERROR_SUCCESS
Definition: deptool.c:10
HRESULT hr
Definition: shlfolder.c:183
#define KEY_READ
Definition: nt_native.h:1023
#define TRUE
Definition: types.h:120
#define WARN(fmt,...)
Definition: debug.h:112
#define RRF_RT_REG_SZ
Definition: driver.c:575
_In_ PSID _Out_writes_to_opt_ cchName LPSTR _Inout_ LPDWORD cchName
Definition: winbase.h:2745
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define FALSE
Definition: types.h:117
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
#define _countof(array)
Definition: sndvol32.h:68
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
REFCLSID clsid
Definition: msctf.c:82
static const WCHAR L[]
Definition: oid.c:1250
#define ERR(fmt,...)
Definition: debug.h:110
#define S_OK
Definition: intsafe.h:51
FxAutoRegKey hKey
#define NULL
Definition: types.h:112
HRESULT WINAPI CLSIDFromString(LPCOLESTR idstr, LPCLSID id)
Definition: compobj.c:2338
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
HRESULT LoadDynamicContextMenuHandler(HKEY hKey, const CLSID *pclsid)
LONG WINAPI RegEnumKeyExW(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
Definition: reg.c:2527
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by QueryContextMenu().

◆ GetCommandString()

HRESULT WINAPI CDefaultContextMenu::GetCommandString ( UINT_PTR  idCommand,
UINT  uFlags,
UINT lpReserved,
LPSTR  lpszName,
UINT  uMaxNameLen 
)
virtual

Implements IContextMenu.

Definition at line 1318 of file CDefaultContextMenu.cpp.

1324 {
1325  /* We don't handle the help text yet */
1326  if (uFlags == GCS_HELPTEXTA ||
1327  uFlags == GCS_HELPTEXTW ||
1328  HIWORD(idCommand) != 0)
1329  {
1330  return E_NOTIMPL;
1331  }
1332 
1333  UINT CmdId = LOWORD(idCommand);
1334 
1335  if (m_pDynamicEntries && CmdId >= m_iIdSHEFirst && CmdId < m_iIdSHELast)
1336  {
1337  idCommand -= m_iIdSHEFirst;
1339  if (!pEntry)
1340  return E_FAIL;
1341 
1342  idCommand -= pEntry->iIdCmdFirst;
1343  return pEntry->pCM->GetCommandString(idCommand,
1344  uFlags,
1345  lpReserved,
1346  lpszName,
1347  uMaxNameLen);
1348  }
1349 
1350  if (m_pStaticEntries && CmdId >= m_iIdSCMFirst && CmdId < m_iIdSCMLast)
1351  {
1352  /* Validation just returns S_OK on a match. The id exists. */
1353  if (uFlags == GCS_VALIDATEA || uFlags == GCS_VALIDATEW)
1354  return S_OK;
1355 
1356  CmdId -= m_iIdSCMFirst;
1357 
1359  while (pEntry && (CmdId--) > 0)
1360  pEntry = pEntry->pNext;
1361 
1362  if (!pEntry)
1363  return E_INVALIDARG;
1364 
1365  if (uFlags == GCS_VERBW)
1366  return StringCchCopyW((LPWSTR)lpszName, uMaxNameLen, pEntry->szVerb);
1367 
1368  if (uFlags == GCS_VERBA)
1369  {
1370  if (SHUnicodeToAnsi(pEntry->szVerb, lpszName, uMaxNameLen))
1371  return S_OK;
1372  }
1373 
1374  return E_INVALIDARG;
1375  }
1376 
1377  //FIXME: Should we handle callbacks here?
1378  if (m_iIdDfltFirst != m_iIdDfltLast && CmdId >= m_iIdDfltFirst && CmdId < m_iIdDfltLast)
1379  {
1380  CmdId -= m_iIdDfltFirst;
1381  /* See the definitions of IDM_CUT and co to see how this works */
1382  CmdId += 0x7000;
1383  }
1384 
1385  /* Loop looking for a matching Id */
1386  for (UINT i = 0; i < _countof(g_StaticInvokeCmdMap); i++)
1387  {
1388  if (g_StaticInvokeCmdMap[i].IntVerb == CmdId)
1389  {
1390  /* Validation just returns S_OK on a match */
1391  if (uFlags == GCS_VALIDATEA || uFlags == GCS_VALIDATEW)
1392  return S_OK;
1393 
1394  /* Return a copy of the ANSI verb */
1395  if (uFlags == GCS_VERBA)
1396  return StringCchCopyA(lpszName, uMaxNameLen, g_StaticInvokeCmdMap[i].szStringVerb);
1397 
1398  /* Convert the ANSI verb to unicode and return that */
1399  if (uFlags == GCS_VERBW)
1400  {
1401  if (SHAnsiToUnicode(g_StaticInvokeCmdMap[i].szStringVerb, (LPWSTR)lpszName, uMaxNameLen))
1402  return S_OK;
1403  }
1404  }
1405  }
1406 
1407  return E_INVALIDARG;
1408 }
struct _StaticInvokeCommandMap_ g_StaticInvokeCmdMap[]
UINT uFlags
Definition: api.c:59
#define E_FAIL
Definition: ddrawi.h:102
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
#define E_INVALIDARG
Definition: ddrawi.h:101
#define _countof(array)
Definition: sndvol32.h:68
DWORD WINAPI SHAnsiToUnicode(LPCSTR lpSrcStr, LPWSTR lpDstStr, int iLen)
Definition: string.c:2659
PDynamicShellEntry GetDynamicEntry(UINT idCmd)
INT WINAPI SHUnicodeToAnsi(LPCWSTR lpSrcStr, LPSTR lpDstStr, INT iLen)
Definition: string.c:2783
STRSAFEAPI StringCchCopyA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPCSTR pszSrc)
Definition: strsafe.h:145
#define S_OK
Definition: intsafe.h:51
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
PDynamicShellEntry m_pDynamicEntries
#define E_NOTIMPL
Definition: ddrawi.h:99
unsigned int UINT
Definition: ndis.h:50
#define HIWORD(l)
Definition: typedefs.h:247
WCHAR * LPWSTR
Definition: xmlstorage.h:184
PStaticShellEntry m_pStaticEntries
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
#define LOWORD(l)
Definition: pedump.c:82

◆ GetDynamicEntry()

PDynamicShellEntry CDefaultContextMenu::GetDynamicEntry ( UINT  idCmd)
private

Definition at line 1002 of file CDefaultContextMenu.cpp.

1003 {
1005 
1006  while(pEntry && idCmd >= pEntry->iIdCmdFirst + pEntry->NumIds)
1007  pEntry = pEntry->pNext;
1008 
1009  if (!pEntry)
1010  return NULL;
1011 
1012  if (idCmd < pEntry->iIdCmdFirst || idCmd > pEntry->iIdCmdFirst + pEntry->NumIds)
1013  return NULL;
1014 
1015  return pEntry;
1016 }
PDynamicShellEntry m_pDynamicEntries
#define NULL
Definition: types.h:112
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484

Referenced by GetCommandString(), HandleMenuMsg2(), and InvokeShellExt().

◆ GetSite()

HRESULT WINAPI CDefaultContextMenu::GetSite ( REFIID  riid,
void **  ppvSite 
)
virtual

Definition at line 1505 of file CDefaultContextMenu.cpp.

1506 {
1507  if (!m_site)
1508  return E_FAIL;
1509 
1510  return m_site->QueryInterface(riid, ppvSite);
1511 }
REFIID riid
Definition: precomp.h:44
#define E_FAIL
Definition: ddrawi.h:102
CComPtr< IUnknown > m_site

◆ HandleMenuMsg()

HRESULT WINAPI CDefaultContextMenu::HandleMenuMsg ( UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
virtual

Implements IContextMenu2.

Definition at line 1412 of file CDefaultContextMenu.cpp.

1416 {
1417  /* FIXME: Should we implement this as well? */
1418  return S_OK;
1419 }
#define S_OK
Definition: intsafe.h:51

◆ HandleMenuMsg2()

HRESULT WINAPI CDefaultContextMenu::HandleMenuMsg2 ( UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
LRESULT plResult 
)
virtual

Implements IContextMenu3.

Definition at line 1459 of file CDefaultContextMenu.cpp.

1464 {
1465  if (uMsg == WM_INITMENUPOPUP)
1466  {
1468  while (pEntry)
1469  {
1470  SHForwardContextMenuMsg(pEntry->pCM, uMsg, wParam, lParam, plResult, TRUE);
1471  pEntry = pEntry->pNext;
1472  }
1473  return S_OK;
1474  }
1475 
1476  UINT CmdId;
1477  HRESULT hr = SHGetMenuIdFromMenuMsg(uMsg, lParam, &CmdId);
1478  if (FAILED(hr))
1479  return S_FALSE;
1480 
1481  if (CmdId < m_iIdSHEFirst || CmdId >= m_iIdSHELast)
1482  return S_FALSE;
1483 
1484  CmdId -= m_iIdSHEFirst;
1486  if (pEntry)
1487  {
1488  SHSetMenuIdInMenuMsg(uMsg, lParam, CmdId - pEntry->iIdCmdFirst);
1489  SHForwardContextMenuMsg(pEntry->pCM, uMsg, wParam, lParam, plResult, TRUE);
1490  }
1491 
1492  return S_OK;
1493 }
HRESULT SHSetMenuIdInMenuMsg(UINT uMsg, LPARAM lParam, UINT CmdId)
HRESULT hr
Definition: shlfolder.c:183
#define TRUE
Definition: types.h:120
#define WM_INITMENUPOPUP
Definition: winuser.h:1728
WPARAM wParam
Definition: combotst.c:138
HRESULT WINAPI SHForwardContextMenuMsg(IUnknown *pUnk, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *pResult, BOOL useIContextMenu2)
Definition: rosordinal.c:11
#define S_FALSE
Definition: winerror.h:2357
LONG HRESULT
Definition: typedefs.h:79
PDynamicShellEntry GetDynamicEntry(UINT idCmd)
#define S_OK
Definition: intsafe.h:51
PDynamicShellEntry m_pDynamicEntries
unsigned int UINT
Definition: ndis.h:50
HRESULT SHGetMenuIdFromMenuMsg(UINT uMsg, LPARAM lParam, UINT *CmdId)
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
LPARAM lParam
Definition: combotst.c:139

◆ Initialize()

HRESULT WINAPI CDefaultContextMenu::Initialize ( const DEFCONTEXTMENU pdcm,
LPFNDFMCALLBACK  lpfn 
)

Definition at line 193 of file CDefaultContextMenu.cpp.

194 {
195  TRACE("cidl %u\n", pdcm->cidl);
196 
197  if (!pdcm->pcmcb && !lpfn)
198  {
199  ERR("CDefaultContextMenu needs a callback!\n");
200  return E_INVALIDARG;
201  }
202 
203  m_cidl = pdcm->cidl;
204  m_apidl = const_cast<PCUITEMID_CHILD_ARRAY>(_ILCopyaPidl(pdcm->apidl, m_cidl));
205  if (m_cidl && !m_apidl)
206  return E_OUTOFMEMORY;
207  m_psf = pdcm->psf;
208  m_pmcb = pdcm->pcmcb;
209  m_pfnmcb = lpfn;
210 
211  m_cKeys = pdcm->cKeys;
212  if (pdcm->cKeys)
213  {
214  m_aKeys = (HKEY*)HeapAlloc(GetProcessHeap(), 0, sizeof(HKEY) * pdcm->cKeys);
215  if (!m_aKeys)
216  return E_OUTOFMEMORY;
217  memcpy(m_aKeys, pdcm->aKeys, sizeof(HKEY) * pdcm->cKeys);
218  }
219 
220  m_psf->GetUIObjectOf(pdcm->hwnd, m_cidl, m_apidl, IID_NULL_PPV_ARG(IDataObject, &m_pDataObj));
221 
222  if (pdcm->pidlFolder)
223  {
225  }
226  else
227  {
229  if (SUCCEEDED(m_psf->QueryInterface(IID_PPV_ARG(IPersistFolder2, &pf))))
230  {
231  if (FAILED(pf->GetCurFolder(&m_pidlFolder)))
232  ERR("GetCurFolder failed\n");
233  }
234  TRACE("pidlFolder %p\n", m_pidlFolder);
235  }
236 
237  return S_OK;
238 }
const HKEY * aKeys
Definition: shlobj.h:2374
IContextMenuCB * pcmcb
Definition: shlobj.h:2367
PIDLIST_ABSOLUTE m_pidlFolder
#define IID_PPV_ARG(Itype, ppType)
IShellFolder * psf
Definition: shlobj.h:2369
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
if SUCCEEDED(hr)
#define E_INVALIDARG
Definition: ddrawi.h:101
#define IID_NULL_PPV_ARG(Itype, ppType)
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
CComPtr< IShellFolder > m_psf
#define ERR(fmt,...)
Definition: debug.h:110
#define S_OK
Definition: intsafe.h:51
CComPtr< IDataObject > m_pDataObj
LPITEMIDLIST WINAPI ILClone(LPCITEMIDLIST pidl)
Definition: pidl.c:228
#define NULL
Definition: types.h:112
HANDLE HKEY
Definition: registry.h:24
CComPtr< IContextMenuCB > m_pmcb
PCUITEMID_CHILD_ARRAY apidl
Definition: shlobj.h:2371
PCIDLIST_ABSOLUTE pidlFolder
Definition: shlobj.h:2368
PITEMID_CHILD * _ILCopyaPidl(PCUITEMID_CHILD_ARRAY apidlsrc, UINT cidl)
Definition: pidl.c:2652
PCUITEMID_CHILD_ARRAY m_apidl

◆ InvokeCommand()

HRESULT WINAPI CDefaultContextMenu::InvokeCommand ( LPCMINVOKECOMMANDINFO  lpcmi)
virtual

Implements IContextMenu.

Definition at line 1218 of file CDefaultContextMenu.cpp.

1220 {
1221  CMINVOKECOMMANDINFO LocalInvokeInfo;
1222  HRESULT Result;
1223  UINT CmdId;
1224 
1225  /* Take a local copy of the fixed members of the
1226  struct as we might need to modify the verb */
1227  LocalInvokeInfo = *lpcmi;
1228 
1229  /* Check if this is a string verb */
1230  if (HIWORD(LocalInvokeInfo.lpVerb))
1231  {
1232  /* Get the ID which corresponds to this verb, and update our local copy */
1233  if (MapVerbToCmdId((LPVOID)LocalInvokeInfo.lpVerb, &CmdId, FALSE))
1234  LocalInvokeInfo.lpVerb = MAKEINTRESOURCEA(CmdId);
1235  }
1236 
1237  CmdId = LOWORD(LocalInvokeInfo.lpVerb);
1238 
1239  if (m_pDynamicEntries && CmdId >= m_iIdSHEFirst && CmdId < m_iIdSHELast)
1240  {
1241  LocalInvokeInfo.lpVerb -= m_iIdSHEFirst;
1242  Result = InvokeShellExt(&LocalInvokeInfo);
1243  return Result;
1244  }
1245 
1246  if (m_pStaticEntries && CmdId >= m_iIdSCMFirst && CmdId < m_iIdSCMLast)
1247  {
1248  LocalInvokeInfo.lpVerb -= m_iIdSCMFirst;
1249  Result = InvokeRegVerb(&LocalInvokeInfo);
1250  return Result;
1251  }
1252 
1253  if (m_iIdCBFirst != m_iIdCBLast && CmdId >= m_iIdCBFirst && CmdId < m_iIdCBLast)
1254  {
1256  return Result;
1257  }
1258 
1259  if (m_iIdDfltFirst != m_iIdDfltLast && CmdId >= m_iIdDfltFirst && CmdId < m_iIdDfltLast)
1260  {
1261  CmdId -= m_iIdDfltFirst;
1262  /* See the definitions of IDM_CUT and co to see how this works */
1263  CmdId += 0x7000;
1264  }
1265 
1266  /* Check if this is a Id */
1267  switch (CmdId)
1268  {
1269  case FCIDM_SHVIEW_INSERT:
1270  Result = DoPaste(&LocalInvokeInfo, FALSE);
1271  break;
1273  Result = DoPaste(&LocalInvokeInfo, TRUE);
1274  break;
1275  case FCIDM_SHVIEW_OPEN:
1276  case FCIDM_SHVIEW_EXPLORE:
1277  Result = DoOpenOrExplore(&LocalInvokeInfo);
1278  break;
1279  case FCIDM_SHVIEW_COPY:
1280  case FCIDM_SHVIEW_CUT:
1281  Result = DoCopyOrCut(&LocalInvokeInfo, CmdId == FCIDM_SHVIEW_COPY);
1282  break;
1284  Result = DoCreateLink(&LocalInvokeInfo);
1285  break;
1286  case FCIDM_SHVIEW_DELETE:
1287  Result = DoDelete(&LocalInvokeInfo);
1288  break;
1289  case FCIDM_SHVIEW_RENAME:
1290  Result = DoRename(&LocalInvokeInfo);
1291  break;
1293  Result = DoProperties(&LocalInvokeInfo);
1294  break;
1296  Result = DoCreateNewFolder(&LocalInvokeInfo);
1297  break;
1298  case FCIDM_SHVIEW_COPYTO:
1299  Result = DoCopyToMoveToFolder(&LocalInvokeInfo, TRUE);
1300  break;
1301  case FCIDM_SHVIEW_MOVETO:
1302  Result = DoCopyToMoveToFolder(&LocalInvokeInfo, FALSE);
1303  break;
1304  case FCIDM_SHVIEW_UNDO:
1305  Result = DoUndo(&LocalInvokeInfo);
1306  break;
1307  default:
1308  Result = E_INVALIDARG;
1309  ERR("Unhandled Verb %xl\n", LOWORD(LocalInvokeInfo.lpVerb));
1310  break;
1311  }
1312 
1313  return Result;
1314 }
#define FCIDM_SHVIEW_UNDO
Definition: shresdef.h:796
HRESULT DoUndo(LPCMINVOKECOMMANDINFO lpcmi)
struct IContextMenu::tagCMINVOKECOMMANDINFO CMINVOKECOMMANDINFO
#define TRUE
Definition: types.h:120
HRESULT DoPaste(LPCMINVOKECOMMANDINFO lpcmi, BOOL bLink)
#define FCIDM_SHVIEW_OPEN
Definition: shresdef.h:820
#define FCIDM_SHVIEW_COPYTO
Definition: shresdef.h:798
#define MAKEINTRESOURCEA(i)
Definition: winuser.h:581
HRESULT DoRename(LPCMINVOKECOMMANDINFO lpcmi)
HRESULT InvokeRegVerb(LPCMINVOKECOMMANDINFO lpcmi)
#define FCIDM_SHVIEW_PROPERTIES
Definition: shresdef.h:792
#define FCIDM_SHVIEW_INSERTLINK
Definition: shresdef.h:797
#define FALSE
Definition: types.h:117
HRESULT DoOpenOrExplore(LPCMINVOKECOMMANDINFO lpcmi)
#define FCIDM_SHVIEW_INSERT
Definition: shresdef.h:795
#define FCIDM_SHVIEW_MOVETO
Definition: shresdef.h:799
#define E_INVALIDARG
Definition: ddrawi.h:101
#define DFM_INVOKECOMMAND
Definition: precomp.h:45
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
#define FCIDM_SHVIEW_NEWFOLDER
Definition: shresdef.h:816
HRESULT InvokeShellExt(LPCMINVOKECOMMANDINFO lpcmi)
#define FCIDM_SHVIEW_EXPLORE
Definition: shresdef.h:819
#define FCIDM_SHVIEW_COPY
Definition: shresdef.h:794
LONG HRESULT
Definition: typedefs.h:79
HRESULT DoProperties(LPCMINVOKECOMMANDINFO lpcmi)
#define FCIDM_SHVIEW_DELETE
Definition: shresdef.h:791
HRESULT DoCopyOrCut(LPCMINVOKECOMMANDINFO lpcmi, BOOL bCopy)
HRESULT DoCreateLink(LPCMINVOKECOMMANDINFO lpcmi)
#define FCIDM_SHVIEW_CREATELINK
Definition: shresdef.h:814
HRESULT DoCreateNewFolder(LPCMINVOKECOMMANDINFO lpici)
#define ERR(fmt,...)
Definition: debug.h:110
#define FCIDM_SHVIEW_RENAME
Definition: shresdef.h:813
PDynamicShellEntry m_pDynamicEntries
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
HRESULT _DoCallback(UINT uMsg, WPARAM wParam, LPVOID lParam)
#define HIWORD(l)
Definition: typedefs.h:247
#define FCIDM_SHVIEW_CUT
Definition: shresdef.h:793
HRESULT DoDelete(LPCMINVOKECOMMANDINFO lpcmi)
PStaticShellEntry m_pStaticEntries
BOOL MapVerbToCmdId(PVOID Verb, PUINT idCmd, BOOL IsUnicode)
#define LOWORD(l)
Definition: pedump.c:82
HRESULT DoCopyToMoveToFolder(LPCMINVOKECOMMANDINFO lpici, BOOL bCopy)

◆ InvokePidl()

HRESULT CDefaultContextMenu::InvokePidl ( LPCMINVOKECOMMANDINFO  lpcmi,
LPCITEMIDLIST  pidl,
PStaticShellEntry  pEntry 
)
private

Definition at line 1128 of file CDefaultContextMenu.cpp.

1129 {
1130  LPITEMIDLIST pidlFull = ILCombine(m_pidlFolder, pidl);
1131  if (pidlFull == NULL)
1132  {
1133  return E_FAIL;
1134  }
1135 
1136  WCHAR wszPath[MAX_PATH];
1137  BOOL bHasPath = SHGetPathFromIDListW(pidlFull, wszPath);
1138 
1139  WCHAR wszDir[MAX_PATH];
1140  if (bHasPath)
1141  {
1142  wcscpy(wszDir, wszPath);
1143  PathRemoveFileSpec(wszDir);
1144  }
1145  else
1146  {
1148  }
1149 
1150  SHELLEXECUTEINFOW sei;
1151  ZeroMemory(&sei, sizeof(sei));
1152  sei.cbSize = sizeof(sei);
1153  sei.hwnd = lpcmi->hwnd;
1154  sei.nShow = SW_SHOWNORMAL;
1155  sei.lpVerb = pEntry->szVerb;
1156  sei.lpDirectory = wszDir;
1157  sei.lpIDList = pidlFull;
1158  sei.hkeyClass = pEntry->hkClass;
1160  if (bHasPath)
1161  {
1162  sei.lpFile = wszPath;
1163  }
1164 
1165  ShellExecuteExW(&sei);
1166 
1167  ILFree(pidlFull);
1168 
1169  return S_OK;
1170 }
#define SEE_MASK_CLASSKEY
Definition: shellapi.h:26
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:925
#define PathRemoveFileSpec
Definition: shlwapi.h:1035
LPITEMIDLIST WINAPI ILCombine(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition: pidl.c:699
BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath)
Definition: pidl.c:1294
PIDLIST_ABSOLUTE m_pidlFolder
#define ZeroMemory
Definition: winbase.h:1664
#define E_FAIL
Definition: ddrawi.h:102
unsigned int BOOL
Definition: ntddk_ex.h:94
LPCWSTR lpDirectory
Definition: shellapi.h:332
BOOL WINAPI DECLSPEC_HOTPATCH ShellExecuteExW(LPSHELLEXECUTEINFOW sei)
Definition: shlexec.cpp:2263
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:34
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define S_OK
Definition: intsafe.h:51
#define SW_SHOWNORMAL
Definition: winuser.h:764
#define SEE_MASK_IDLIST
Definition: shellapi.h:27
#define NULL
Definition: types.h:112
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41

Referenced by InvokeRegVerb().

◆ InvokeRegVerb()

HRESULT CDefaultContextMenu::InvokeRegVerb ( LPCMINVOKECOMMANDINFO  lpcmi)
private

Definition at line 1173 of file CDefaultContextMenu.cpp.

1175 {
1177  INT iCmd = LOWORD(lpcmi->lpVerb) - m_iIdSCMFirst;
1178  HRESULT hr;
1179  UINT i;
1180 
1181  while (pEntry && (iCmd--) > 0)
1182  pEntry = pEntry->pNext;
1183 
1184  if (iCmd > 0)
1185  return E_FAIL;
1186 
1187  /* Get the browse flags to see if we need to browse */
1189  BOOL bBrowsed = FALSE;
1190 
1191  for (i=0; i < m_cidl; i++)
1192  {
1193  /* Check if we need to browse */
1194  if (wFlags > 0)
1195  {
1196  /* In xp if we have browsed, we don't open any more folders.
1197  * In win7 we browse to the first folder we find and
1198  * open new windows for each of the rest of the folders */
1199  if (bBrowsed)
1200  continue;
1201 
1202  hr = TryToBrowse(lpcmi, m_apidl[i], wFlags);
1203  if (SUCCEEDED(hr))
1204  {
1205  bBrowsed = TRUE;
1206  continue;
1207  }
1208  }
1209 
1210  InvokePidl(lpcmi, m_apidl[i], pEntry);
1211  }
1212 
1213  return S_OK;
1214 }
HRESULT hr
Definition: shlfolder.c:183
#define TRUE
Definition: types.h:120
#define E_FAIL
Definition: ddrawi.h:102
int32_t INT
Definition: typedefs.h:58
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
HRESULT TryToBrowse(LPCMINVOKECOMMANDINFO lpcmi, LPCITEMIDLIST pidl, DWORD wFlags)
if SUCCEEDED(hr)
LONG HRESULT
Definition: typedefs.h:79
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_ DWORD _Out_ _In_ WORD wFlags
Definition: wincon.h:531
DWORD BrowserFlagsFromVerb(LPCMINVOKECOMMANDINFO lpcmi, PStaticShellEntry pEntry)
#define S_OK
Definition: intsafe.h:51
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int UINT
Definition: ndis.h:50
HRESULT InvokePidl(LPCMINVOKECOMMANDINFO lpcmi, LPCITEMIDLIST pidl, PStaticShellEntry pEntry)
PStaticShellEntry m_pStaticEntries
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
#define LOWORD(l)
Definition: pedump.c:82
PCUITEMID_CHILD_ARRAY m_apidl

Referenced by InvokeCommand().

◆ InvokeShellExt()

HRESULT CDefaultContextMenu::InvokeShellExt ( LPCMINVOKECOMMANDINFO  lpcmi)
private

Definition at line 1055 of file CDefaultContextMenu.cpp.

1057 {
1058  TRACE("verb %p first %x last %x\n", lpcmi->lpVerb, m_iIdSHEFirst, m_iIdSHELast);
1059 
1060  UINT idCmd = LOWORD(lpcmi->lpVerb);
1062  if (!pEntry)
1063  return E_FAIL;
1064 
1065  /* invoke the dynamic context menu */
1066  lpcmi->lpVerb = MAKEINTRESOURCEA(idCmd - pEntry->iIdCmdFirst);
1067  return pEntry->pCM->InvokeCommand(lpcmi);
1068 }
#define MAKEINTRESOURCEA(i)
Definition: winuser.h:581
#define E_FAIL
Definition: ddrawi.h:102
#define TRACE(s)
Definition: solgame.cpp:4
PDynamicShellEntry GetDynamicEntry(UINT idCmd)
unsigned int UINT
Definition: ndis.h:50
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
#define LOWORD(l)
Definition: pedump.c:82

Referenced by InvokeCommand().

◆ IsShellExtensionAlreadyLoaded()

BOOL CDefaultContextMenu::IsShellExtensionAlreadyLoaded ( const CLSID pclsid)
private

Definition at line 336 of file CDefaultContextMenu.cpp.

337 {
339 
340  while (pEntry)
341  {
342  if (!memcmp(&pEntry->ClassID, pclsid, sizeof(CLSID)))
343  return TRUE;
344  pEntry = pEntry->pNext;
345  }
346 
347  return FALSE;
348 }
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
PDynamicShellEntry m_pDynamicEntries
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484

Referenced by LoadDynamicContextMenuHandler().

◆ LoadDynamicContextMenuHandler()

HRESULT CDefaultContextMenu::LoadDynamicContextMenuHandler ( HKEY  hKey,
const CLSID pclsid 
)
private

Definition at line 351 of file CDefaultContextMenu.cpp.

352 {
353  HRESULT hr;
354 
355  TRACE("LoadDynamicContextMenuHandler entered with This %p hKey %p pclsid %s\n", this, hKey, wine_dbgstr_guid(pclsid));
356 
357  if (IsShellExtensionAlreadyLoaded(pclsid))
358  return S_OK;
359 
362  if (FAILED(hr))
363  {
364  ERR("SHCoCreateInstance(IContextMenu) failed.clsid %s hr 0x%x\n", wine_dbgstr_guid(pclsid), hr);
365  return hr;
366  }
367 
368  CComPtr<IShellExtInit> pExtInit;
369  hr = pcm->QueryInterface(IID_PPV_ARG(IShellExtInit, &pExtInit));
370  if (FAILED(hr))
371  {
372  ERR("IContextMenu->QueryInterface(IShellExtInit) failed.clsid %s hr 0x%x\n", wine_dbgstr_guid(pclsid), hr);
373  return hr;
374  }
375 
376  hr = pExtInit->Initialize(m_pidlFolder, m_pDataObj, hKey);
377  if (FAILED(hr))
378  {
379  WARN("IShellExtInit::Initialize failed.clsid %s hr 0x%x\n", wine_dbgstr_guid(pclsid), hr);
380  return hr;
381  }
382 
383  if (m_site)
384  IUnknown_SetSite(pcm, m_site);
385 
387  if (!pEntry)
388  return E_OUTOFMEMORY;
389 
390  pEntry->iIdCmdFirst = 0;
391  pEntry->pNext = NULL;
392  pEntry->NumIds = 0;
393  pEntry->pCM = pcm.Detach();
394  memcpy(&pEntry->ClassID, pclsid, sizeof(CLSID));
395 
396  if (m_pDynamicEntries)
397  {
399 
400  while (pLastEntry->pNext)
401  pLastEntry = pLastEntry->pNext;
402 
403  pLastEntry->pNext = pEntry;
404  }
405  else
407 
408  return S_OK;
409 }
HRESULT hr
Definition: shlfolder.c:183
#define WARN(fmt,...)
Definition: debug.h:112
PIDLIST_ABSOLUTE m_pidlFolder
const char * wine_dbgstr_guid(const GUID *guid)
#define IID_PPV_ARG(Itype, ppType)
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
HRESULT WINAPI IUnknown_SetSite(IUnknown *obj, IUnknown *site)
Definition: ordinal.c:1404
HRESULT WINAPI SHCoCreateInstance(LPCWSTR aclsid, const CLSID *clsid, LPUNKNOWN pUnkOuter, REFIID refiid, LPVOID *ppv)
Definition: shellole.c:105
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG HRESULT
Definition: typedefs.h:79
BOOL IsShellExtensionAlreadyLoaded(const CLSID *pclsid)
struct _DynamicShellEntry_ * pNext
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
CComPtr< IUnknown > m_site
#define ERR(fmt,...)
Definition: debug.h:110
#define S_OK
Definition: intsafe.h:51
CComPtr< IDataObject > m_pDataObj
PDynamicShellEntry m_pDynamicEntries
FxAutoRegKey hKey
#define NULL
Definition: types.h:112
T * Detach()
Definition: atlcomcli.h:156
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
struct _DynamicShellEntry_ DynamicShellEntry

Referenced by EnumerateDynamicContextHandlerForKey().

◆ MapVerbToCmdId()

BOOL CDefaultContextMenu::MapVerbToCmdId ( PVOID  Verb,
PUINT  idCmd,
BOOL  IsUnicode 
)
private

Definition at line 1022 of file CDefaultContextMenu.cpp.

1023 {
1024  WCHAR UnicodeStr[MAX_VERB];
1025 
1026  /* Loop through all the static verbs looking for a match */
1027  for (UINT i = 0; i < _countof(g_StaticInvokeCmdMap); i++)
1028  {
1029  /* We can match both ANSI and unicode strings */
1030  if (IsUnicode)
1031  {
1032  /* The static verbs are ANSI, get a unicode version before doing the compare */
1033  SHAnsiToUnicode(g_StaticInvokeCmdMap[i].szStringVerb, UnicodeStr, MAX_VERB);
1034  if (!wcscmp(UnicodeStr, (LPWSTR)Verb))
1035  {
1036  /* Return the Corresponding Id */
1037  *idCmd = g_StaticInvokeCmdMap[i].IntVerb;
1038  return TRUE;
1039  }
1040  }
1041  else
1042  {
1043  if (!strcmp(g_StaticInvokeCmdMap[i].szStringVerb, (LPSTR)Verb))
1044  {
1045  *idCmd = g_StaticInvokeCmdMap[i].IntVerb;
1046  return TRUE;
1047  }
1048  }
1049  }
1050 
1051  return FALSE;
1052 }
struct _StaticInvokeCommandMap_ g_StaticInvokeCmdMap[]
#define TRUE
Definition: types.h:120
char * LPSTR
Definition: xmlstorage.h:182
#define FALSE
Definition: types.h:117
#define MAX_VERB
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
DWORD WINAPI SHAnsiToUnicode(LPCSTR lpSrcStr, LPWSTR lpDstStr, int iLen)
Definition: string.c:2659
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int UINT
Definition: ndis.h:50
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by InvokeCommand().

◆ QueryContextMenu()

HRESULT WINAPI CDefaultContextMenu::QueryContextMenu ( HMENU  hMenu,
UINT  indexMenu,
UINT  idCmdFirst,
UINT  idCmdLast,
UINT  uFlags 
)
virtual

Implements IContextMenu.

Definition at line 667 of file CDefaultContextMenu.cpp.

673 {
674  HRESULT hr;
675  UINT idCmdNext = idCmdFirst;
676  UINT cIds = 0;
677 
678  TRACE("BuildShellItemContextMenu entered\n");
679 
680  /* Load static verbs and shell extensions from registry */
681  for (UINT i = 0; i < m_cKeys; i++)
682  {
685  }
686 
687  /* Add static context menu handlers */
688  cIds = AddStaticContextMenusToMenu(hMenu, &IndexMenu, idCmdFirst, idCmdLast);
689  m_iIdSCMFirst = 0;
690  m_iIdSCMLast = cIds;
691  idCmdNext = idCmdFirst + cIds;
692 
693  /* Add dynamic context menu handlers */
694  cIds += AddShellExtensionsToMenu(hMenu, &IndexMenu, idCmdNext, idCmdLast);
696  m_iIdSHELast = cIds;
697  idCmdNext = idCmdFirst + cIds;
698  TRACE("SH_LoadContextMenuHandlers first %x last %x\n", m_iIdSHEFirst, m_iIdSHELast);
699 
700  /* Now let the callback add its own items */
701  QCMINFO qcminfo = {hMenu, IndexMenu, idCmdNext, idCmdLast, NULL};
703  {
704  cIds += qcminfo.idCmdFirst;
705  IndexMenu += qcminfo.idCmdFirst;
707  m_iIdCBLast = cIds;
708  idCmdNext = idCmdFirst + cIds;
709  }
710 
711  if (uFlags & CMF_VERBSONLY)
712  return MAKE_HRESULT(SEVERITY_SUCCESS, 0, cIds);
713 
714  /* If this is a background context menu we are done */
715  if (!m_cidl)
716  return MAKE_HRESULT(SEVERITY_SUCCESS, 0, cIds);
717 
718  /* Get the attributes of the items */
719  SFGAOF rfg = SFGAO_BROWSABLE | SFGAO_CANCOPY | SFGAO_CANLINK | SFGAO_CANMOVE | SFGAO_CANDELETE | SFGAO_CANRENAME | SFGAO_HASPROPSHEET | SFGAO_FILESYSTEM | SFGAO_FOLDER;
720  hr = m_psf->GetAttributesOf(m_cidl, m_apidl, &rfg);
721  if (FAILED_UNEXPECTEDLY(hr))
722  return MAKE_HRESULT(SEVERITY_SUCCESS, 0, cIds);
723 
724  /* Add the default part of the menu */
725  HMENU hmenuDefault = LoadMenu(_AtlBaseModule.GetResourceInstance(), L"MENU_SHV_FILE");
726 
727  /* Remove uneeded entries */
728  if (!(rfg & SFGAO_CANMOVE))
729  DeleteMenu(hmenuDefault, IDM_CUT, MF_BYCOMMAND);
730  if (!(rfg & SFGAO_CANCOPY))
731  DeleteMenu(hmenuDefault, IDM_COPY, MF_BYCOMMAND);
732  if (!((rfg & SFGAO_FILESYSTEM) && HasClipboardData()))
733  DeleteMenu(hmenuDefault, IDM_INSERT, MF_BYCOMMAND);
734  if (!(rfg & SFGAO_CANLINK))
735  DeleteMenu(hmenuDefault, IDM_CREATELINK, MF_BYCOMMAND);
736  if (!(rfg & SFGAO_CANDELETE))
737  DeleteMenu(hmenuDefault, IDM_DELETE, MF_BYCOMMAND);
738  if (!(rfg & SFGAO_CANRENAME))
739  DeleteMenu(hmenuDefault, IDM_RENAME, MF_BYCOMMAND);
740  if (!(rfg & SFGAO_HASPROPSHEET))
741  DeleteMenu(hmenuDefault, IDM_PROPERTIES, MF_BYCOMMAND);
742 
743  UINT idMax = Shell_MergeMenus(hMenu, GetSubMenu(hmenuDefault, 0), IndexMenu, idCmdNext, idCmdLast, 0);
744  m_iIdDfltFirst = cIds;
745  cIds += idMax - idCmdNext;
746  m_iIdDfltLast = cIds;
747 
748  DestroyMenu(hmenuDefault);
749 
750  return MAKE_HRESULT(SEVERITY_SUCCESS, 0, cIds);
751 }
#define MF_BYCOMMAND
Definition: winuser.h:202
UINT AddStaticContextMenusToMenu(HMENU hMenu, UINT *IndexMenu, UINT iIdCmdFirst, UINT iIdCmdLast)
UINT WINAPI Shell_MergeMenus(HMENU hmDst, HMENU hmSrc, UINT uInsert, UINT uIDAdjust, UINT uIDAdjustMax, ULONG uFlags)
Definition: shlmenu.c:857
HRESULT hr
Definition: shlfolder.c:183
#define IDM_RENAME
Definition: shresdef.h:834
UINT uFlags
Definition: api.c:59
#define IDM_COPY
Definition: shresdef.h:830
#define SEVERITY_SUCCESS
Definition: winerror.h:64
if SUCCEEDED(hr)
#define MAKE_HRESULT(sev, fac, code)
Definition: dmerror.h:30
#define IDM_DELETE
Definition: shresdef.h:833
BOOL EnumerateDynamicContextHandlerForKey(HKEY hRootKey)
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:79
BOOL WINAPI DeleteMenu(_In_ HMENU, _In_ UINT, _In_ UINT)
UINT idCmdFirst
Definition: shlobj.h:1317
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
#define DFM_MERGECONTEXTMENU
Definition: precomp.h:44
static const WCHAR L[]
Definition: oid.c:1250
#define IDM_PROPERTIES
Definition: resources.h:9
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
BOOL WINAPI DestroyMenu(_In_ HMENU)
CComPtr< IShellFolder > m_psf
#define LoadMenu
Definition: winuser.h:5792
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
#define IDM_CUT
Definition: shresdef.h:829
HRESULT _DoCallback(UINT uMsg, WPARAM wParam, LPVOID lParam)
UINT AddShellExtensionsToMenu(HMENU hMenu, UINT *pIndexMenu, UINT idCmdFirst, UINT idCmdLast)
#define IDM_CREATELINK
Definition: shresdef.h:832
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
void AddStaticEntriesForKey(HKEY hKey)
#define IDM_INSERT
Definition: shresdef.h:831
static BOOL HasClipboardData()
static IShellFolder IShellItem **static IBindCtx LPITEMIDLIST SFGAOF
Definition: ebrowser.c:83
PCUITEMID_CHILD_ARRAY m_apidl

◆ SetSite()

HRESULT WINAPI CDefaultContextMenu::SetSite ( IUnknown pUnkSite)
virtual

Implements IObjectWithSite.

Definition at line 1497 of file CDefaultContextMenu.cpp.

1498 {
1499  m_site = pUnkSite;
1500  return S_OK;
1501 }
CComPtr< IUnknown > m_site
#define S_OK
Definition: intsafe.h:51

◆ TryToBrowse()

HRESULT CDefaultContextMenu::TryToBrowse ( LPCMINVOKECOMMANDINFO  lpcmi,
LPCITEMIDLIST  pidl,
DWORD  wFlags 
)
private

Definition at line 1110 of file CDefaultContextMenu.cpp.

1112 {
1114  HRESULT hr;
1115 
1116  if (!m_site)
1117  return E_FAIL;
1118 
1119  /* Get a pointer to the shell browser */
1121  if (FAILED_UNEXPECTEDLY(hr))
1122  return 0;
1123 
1124  return psb->BrowseObject(ILCombine(m_pidlFolder, pidl), wFlags);
1125 }
HRESULT hr
Definition: shlfolder.c:183
LPITEMIDLIST WINAPI ILCombine(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition: pidl.c:699
PIDLIST_ABSOLUTE m_pidlFolder
#define IID_PPV_ARG(Itype, ppType)
#define E_FAIL
Definition: ddrawi.h:102
HRESULT WINAPI IUnknown_QueryService(IUnknown *, REFGUID, REFIID, LPVOID *)
Definition: ordinal.c:1494
LONG HRESULT
Definition: typedefs.h:79
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
CComPtr< IUnknown > m_site
_In_ DWORD _Out_ _In_ WORD wFlags
Definition: wincon.h:531
#define SID_IShellBrowser

Referenced by InvokeRegVerb().

Member Data Documentation

◆ m_aKeys

HKEY* CDefaultContextMenu::m_aKeys
private

Definition at line 68 of file CDefaultContextMenu.cpp.

Referenced by Initialize(), QueryContextMenu(), and ~CDefaultContextMenu().

◆ m_apidl

PCUITEMID_CHILD_ARRAY CDefaultContextMenu::m_apidl
private

◆ m_bGroupPolicyActive

DWORD CDefaultContextMenu::m_bGroupPolicyActive
private

Definition at line 71 of file CDefaultContextMenu.cpp.

Referenced by EnumerateDynamicContextHandlerForKey().

◆ m_cidl

UINT CDefaultContextMenu::m_cidl
private

◆ m_cKeys

UINT CDefaultContextMenu::m_cKeys
private

Definition at line 69 of file CDefaultContextMenu.cpp.

Referenced by Initialize(), QueryContextMenu(), and ~CDefaultContextMenu().

◆ m_iIdCBFirst

UINT CDefaultContextMenu::m_iIdCBFirst
private

Definition at line 78 of file CDefaultContextMenu.cpp.

Referenced by InvokeCommand(), and QueryContextMenu().

◆ m_iIdCBLast

UINT CDefaultContextMenu::m_iIdCBLast
private

Definition at line 79 of file CDefaultContextMenu.cpp.

Referenced by InvokeCommand(), and QueryContextMenu().

◆ m_iIdDfltFirst

UINT CDefaultContextMenu::m_iIdDfltFirst
private

Definition at line 80 of file CDefaultContextMenu.cpp.

Referenced by GetCommandString(), InvokeCommand(), and QueryContextMenu().

◆ m_iIdDfltLast

UINT CDefaultContextMenu::m_iIdDfltLast
private

Definition at line 81 of file CDefaultContextMenu.cpp.

Referenced by GetCommandString(), InvokeCommand(), and QueryContextMenu().

◆ m_iIdSCMFirst

UINT CDefaultContextMenu::m_iIdSCMFirst
private

◆ m_iIdSCMLast

UINT CDefaultContextMenu::m_iIdSCMLast
private

Definition at line 77 of file CDefaultContextMenu.cpp.

Referenced by GetCommandString(), InvokeCommand(), and QueryContextMenu().

◆ m_iIdSHEFirst

UINT CDefaultContextMenu::m_iIdSHEFirst
private

◆ m_iIdSHELast

UINT CDefaultContextMenu::m_iIdSHELast
private

◆ m_pDataObj

CComPtr<IDataObject> CDefaultContextMenu::m_pDataObj
private

◆ m_pDynamicEntries

◆ m_pfnmcb

LPFNDFMCALLBACK CDefaultContextMenu::m_pfnmcb
private

Definition at line 64 of file CDefaultContextMenu.cpp.

Referenced by _DoCallback(), and Initialize().

◆ m_pidlFolder

◆ m_pmcb

CComPtr<IContextMenuCB> CDefaultContextMenu::m_pmcb
private

Definition at line 63 of file CDefaultContextMenu.cpp.

Referenced by _DoCallback(), and Initialize().

◆ m_psf

CComPtr<IShellFolder> CDefaultContextMenu::m_psf
private

◆ m_pStaticEntries

PStaticShellEntry CDefaultContextMenu::m_pStaticEntries
private

◆ m_site

CComPtr<IUnknown> CDefaultContextMenu::m_site
private

The documentation for this class was generated from the following file: