ReactOS  0.4.15-dev-5446-g3f3714b
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 (REFCLSID clsid)
 
HRESULT LoadDynamicContextMenuHandler (HKEY hKey, REFCLSID clsid)
 
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 (LPCMINVOKECOMMANDINFOEX lpcmi, BOOL bLink)
 
HRESULT DoOpenOrExplore (LPCMINVOKECOMMANDINFOEX lpcmi)
 
HRESULT DoCreateLink (LPCMINVOKECOMMANDINFOEX lpcmi)
 
HRESULT DoDelete (LPCMINVOKECOMMANDINFOEX lpcmi)
 
HRESULT DoCopyOrCut (LPCMINVOKECOMMANDINFOEX lpcmi, BOOL bCopy)
 
HRESULT DoRename (LPCMINVOKECOMMANDINFOEX lpcmi)
 
HRESULT DoProperties (LPCMINVOKECOMMANDINFOEX lpcmi)
 
HRESULT DoUndo (LPCMINVOKECOMMANDINFOEX lpcmi)
 
HRESULT DoCreateNewFolder (LPCMINVOKECOMMANDINFOEX lpici)
 
HRESULT DoCopyToMoveToFolder (LPCMINVOKECOMMANDINFOEX lpici, BOOL bCopy)
 
HRESULT InvokeShellExt (LPCMINVOKECOMMANDINFOEX lpcmi)
 
HRESULT InvokeRegVerb (LPCMINVOKECOMMANDINFOEX lpcmi)
 
DWORD BrowserFlagsFromVerb (LPCMINVOKECOMMANDINFOEX lpcmi, PStaticShellEntry pEntry)
 
HRESULT TryToBrowse (LPCMINVOKECOMMANDINFOEX lpcmi, LPCITEMIDLIST pidl, DWORD wFlags)
 
HRESULT InvokePidl (LPCMINVOKECOMMANDINFOEX 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
 
CAtlList< DynamicShellEntrym_DynamicEntries
 
UINT m_iIdSHEFirst
 
UINT m_iIdSHELast
 
CAtlList< StaticShellEntrym_StaticEntries
 
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 53 of file CDefaultContextMenu.cpp.

Constructor & Destructor Documentation

◆ CDefaultContextMenu()

CDefaultContextMenu::CDefaultContextMenu ( )

Definition at line 135 of file CDefaultContextMenu.cpp.

135  :
136  m_psf(NULL),
137  m_pmcb(NULL),
138  m_pfnmcb(NULL),
139  m_cidl(0),
140  m_apidl(NULL),
141  m_pDataObj(NULL),
142  m_aKeys(NULL),
143  m_cKeys(NULL),
146  m_iIdSHEFirst(0),
147  m_iIdSHELast(0),
148  m_iIdSCMFirst(0),
149  m_iIdSCMLast(0),
150  m_iIdCBFirst(0),
151  m_iIdCBLast(0),
152  m_iIdDfltFirst(0),
153  m_iIdDfltLast(0)
154 {
155 }
PIDLIST_ABSOLUTE m_pidlFolder
CComPtr< IShellFolder > m_psf
CComPtr< IDataObject > m_pDataObj
#define NULL
Definition: types.h:112
CComPtr< IContextMenuCB > m_pmcb
PCUITEMID_CHILD_ARRAY m_apidl

◆ ~CDefaultContextMenu()

CDefaultContextMenu::~CDefaultContextMenu ( )

Definition at line 157 of file CDefaultContextMenu.cpp.

158 {
159  m_DynamicEntries.RemoveAll();
160  m_StaticEntries.RemoveAll();
161 
162  for (UINT i = 0; i < m_cKeys; i++)
165 
166  if (m_pidlFolder)
168  _ILFreeaPidl(const_cast<PITEMID_CHILD *>(m_apidl), m_cidl);
169 }
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
CAtlList< DynamicShellEntry > m_DynamicEntries
PIDLIST_ABSOLUTE m_pidlFolder
CAtlList< StaticShellEntry > m_StaticEntries
#define GetProcessHeap()
Definition: compat.h:736
void _ILFreeaPidl(LPITEMIDLIST *apidl, UINT cidl)
Definition: pidl.c:2646
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 HeapFree(x, y, z)
Definition: compat.h:735
#define RegCloseKey(hKey)
Definition: registry.h:47
PCUITEMID_CHILD_ARRAY m_apidl

Member Function Documentation

◆ _DoCallback()

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

Definition at line 218 of file CDefaultContextMenu.cpp.

219 {
220  if (m_pmcb)
221  {
222  return m_pmcb->CallBack(m_psf, NULL, m_pDataObj, uMsg, wParam, (LPARAM)lParam);
223  }
224  else if(m_pfnmcb)
225  {
226  return m_pfnmcb(m_psf, NULL, m_pDataObj, uMsg, wParam, (LPARAM)lParam);
227  }
228 
229  return E_FAIL;
230 }
#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 420 of file CDefaultContextMenu.cpp.

421 {
422  UINT cIds = 0;
423 
424  if (m_DynamicEntries.IsEmpty())
425  return cIds;
426 
427  POSITION it = m_DynamicEntries.GetHeadPosition();
428  while (it != NULL)
429  {
430  DynamicShellEntry& info = m_DynamicEntries.GetNext(it);
431 
432  HRESULT hr = info.pCM->QueryContextMenu(hMenu, *pIndexMenu, idCmdFirst + cIds, idCmdLast, CMF_NORMAL);
433  if (SUCCEEDED(hr))
434  {
435  info.iIdCmdFirst = cIds;
436  info.NumIds = HRESULT_CODE(hr);
437  (*pIndexMenu) += info.NumIds;
438 
439  cIds += info.NumIds;
440  if (idCmdFirst + cIds >= idCmdLast)
441  break;
442  }
443  TRACE("pEntry hr %x contextmenu %p cmdfirst %x num ids %x\n", hr, info.pCM.p, info.iIdCmdFirst, info.NumIds);
444  }
445  return cIds;
446 }
HRESULT hr
Definition: shlfolder.c:183
CAtlList< DynamicShellEntry > m_DynamicEntries
if SUCCEEDED(hr)
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:79
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
#define HRESULT_CODE(hr)
Definition: winerror.h:76

Referenced by QueryContextMenu().

◆ AddStaticContextMenusToMenu()

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

Definition at line 449 of file CDefaultContextMenu.cpp.

454 {
455  MENUITEMINFOW mii;
456  UINT idResource;
457  WCHAR wszVerb[40];
458  UINT fState;
459  UINT cIds = 0;
460 
461  mii.cbSize = sizeof(mii);
463  mii.fType = MFT_STRING;
464  mii.dwTypeData = NULL;
465 
466  POSITION it = m_StaticEntries.GetHeadPosition();
467  bool first = true;
468  while (it != NULL)
469  {
470  StaticShellEntry& info = m_StaticEntries.GetNext(it);
471 
472  fState = MFS_ENABLED;
473  mii.dwTypeData = NULL;
474 
475  /* set first entry as default */
476  if (first)
477  {
478  fState |= MFS_DEFAULT;
479  first = false;
480  }
481 
482  if (info.Verb.CompareNoCase(L"open") == 0)
483  {
484  /* override default when open verb is found */
485  fState |= MFS_DEFAULT;
486  idResource = IDS_OPEN_VERB;
487  }
488  else if (info.Verb.CompareNoCase(L"explore") == 0)
489  idResource = IDS_EXPLORE_VERB;
490  else if (info.Verb.CompareNoCase(L"runas") == 0)
491  idResource = IDS_RUNAS_VERB;
492  else if (info.Verb.CompareNoCase(L"edit") == 0)
493  idResource = IDS_EDIT_VERB;
494  else if (info.Verb.CompareNoCase(L"find") == 0)
495  idResource = IDS_FIND_VERB;
496  else if (info.Verb.CompareNoCase(L"print") == 0)
497  idResource = IDS_PRINT_VERB;
498  else if (info.Verb.CompareNoCase(L"printto") == 0)
499  {
500  continue;
501  }
502  else
503  idResource = 0;
504 
505  /* By default use verb for menu item name */
506  mii.dwTypeData = (LPWSTR)info.Verb.GetString();
507 
508  WCHAR wszKey[256];
509  HRESULT hr;
510  hr = StringCbPrintfW(wszKey, sizeof(wszKey), L"shell\\%s", info.Verb.GetString());
511  if (FAILED_UNEXPECTEDLY(hr))
512  {
513  continue;
514  }
515 
516  BOOL Extended = FALSE;
517  HKEY hkVerb;
518  if (idResource > 0)
519  {
520  if (LoadStringW(shell32_hInstance, idResource, wszVerb, _countof(wszVerb)))
521  mii.dwTypeData = wszVerb; /* use translated verb */
522  else
523  ERR("Failed to load string\n");
524 
525  LONG res = RegOpenKeyW(info.hkClass, wszKey, &hkVerb);
526  if (res == ERROR_SUCCESS)
527  {
528  res = RegQueryValueExW(hkVerb, L"Extended", NULL, NULL, NULL, NULL);
529  Extended = (res == ERROR_SUCCESS);
530 
531  RegCloseKey(hkVerb);
532  }
533  }
534  else
535  {
536  LONG res = RegOpenKeyW(info.hkClass, wszKey, &hkVerb);
537  if (res == ERROR_SUCCESS)
538  {
539  DWORD cbVerb = sizeof(wszVerb);
540  res = RegLoadMUIStringW(hkVerb, NULL, wszVerb, cbVerb, NULL, 0, NULL);
541  if (res == ERROR_SUCCESS)
542  {
543  /* use description for the menu entry */
544  mii.dwTypeData = wszVerb;
545  }
546 
547  res = RegQueryValueExW(hkVerb, L"Extended", NULL, NULL, NULL, NULL);
548  Extended = (res == ERROR_SUCCESS);
549 
550  RegCloseKey(hkVerb);
551  }
552  }
553 
554  if (!Extended || GetAsyncKeyState(VK_SHIFT) < 0)
555  {
556  mii.cch = wcslen(mii.dwTypeData);
557  mii.fState = fState;
558  mii.wID = iIdCmdFirst + cIds;
559  InsertMenuItemW(hMenu, *pIndexMenu, TRUE, &mii);
560  (*pIndexMenu)++;
561  cIds++;
562  }
563 
564  if (mii.wID >= iIdCmdLast)
565  break;
566  }
567 
568  return cIds;
569 }
#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
const GLint * first
Definition: glext.h:5794
LPWSTR dwTypeData
Definition: winuser.h:3259
#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
CAtlList< StaticShellEntry > m_StaticEntries
#define L(x)
Definition: ntvdm.h:50
#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:3291
#define VK_SHIFT
Definition: winuser.h:2192
#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:4120
__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:82
unsigned long DWORD
Definition: ntddk_ex.h:95
#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
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define MIIM_DATA
Definition: winuser.h:721
#define RegCloseKey(hKey)
Definition: registry.h:47

Referenced by QueryContextMenu().

◆ AddStaticEntriesForKey()

void CDefaultContextMenu::AddStaticEntriesForKey ( HKEY  hKey)
private

Definition at line 258 of file CDefaultContextMenu.cpp.

259 {
260  WCHAR wszName[40];
261  DWORD cchName, dwIndex = 0;
262  HKEY hShellKey;
263 
264  LRESULT lres = RegOpenKeyExW(hKey, L"shell", 0, KEY_READ, &hShellKey);
265  if (lres != STATUS_SUCCESS)
266  return;
267 
268  while(TRUE)
269  {
270  cchName = _countof(wszName);
271  if (RegEnumKeyExW(hShellKey, dwIndex++, wszName, &cchName, NULL, NULL, NULL, NULL) != ERROR_SUCCESS)
272  break;
273 
274  AddStaticEntry(hKey, wszName);
275  }
276 
277  RegCloseKey(hShellKey);
278 }
#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:2753
#define L(x)
Definition: ntvdm.h:50
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
unsigned long DWORD
Definition: ntddk_ex.h:95
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:3356
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
#define RegCloseKey(hKey)
Definition: registry.h:47

Referenced by QueryContextMenu().

◆ AddStaticEntry()

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

Definition at line 232 of file CDefaultContextMenu.cpp.

233 {
234  POSITION it = m_StaticEntries.GetHeadPosition();
235  while (it != NULL)
236  {
237  const StaticShellEntry& info = m_StaticEntries.GetNext(it);
238  if (info.Verb.CompareNoCase(szVerb) == 0)
239  {
240  /* entry already exists */
241  return;
242  }
243  }
244 
245  TRACE("adding verb %s\n", debugstr_w(szVerb));
246 
247  if (!wcsicmp(szVerb, L"open"))
248  {
249  /* open verb is always inserted in front */
250  m_StaticEntries.AddHead({ szVerb, hkeyClass });
251  }
252  else
253  {
254  m_StaticEntries.AddTail({ szVerb, hkeyClass });
255  }
256 }
CAtlList< StaticShellEntry > m_StaticEntries
#define L(x)
Definition: ntvdm.h:50
#define debugstr_w
Definition: kernel32.h:32
#define TRACE(s)
Definition: solgame.cpp:4
#define wcsicmp
Definition: compat.h:15
#define NULL
Definition: types.h:112

Referenced by AddStaticEntriesForKey().

◆ BrowserFlagsFromVerb()

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

Definition at line 1028 of file CDefaultContextMenu.cpp.

1029 {
1031  HWND hwndTree;
1032  LPCWSTR FlagsName;
1033  WCHAR wszKey[256];
1034  HRESULT hr;
1035  DWORD wFlags;
1036  DWORD cbVerb;
1037 
1038  if (!m_site)
1039  return 0;
1040 
1041  /* Get a pointer to the shell browser */
1043  if (FAILED_UNEXPECTEDLY(hr))
1044  return 0;
1045 
1046  /* See if we are in Explore or Browse mode. If the browser's tree is present, we are in Explore mode.*/
1047  if (SUCCEEDED(psb->GetControlWindow(FCW_TREE, &hwndTree)) && hwndTree)
1048  FlagsName = L"ExplorerFlags";
1049  else
1050  FlagsName = L"BrowserFlags";
1051 
1052  /* Try to get the flag from the verb */
1053  hr = StringCbPrintfW(wszKey, sizeof(wszKey), L"shell\\%s", pEntry->Verb.GetString());
1054  if (FAILED_UNEXPECTEDLY(hr))
1055  return 0;
1056 
1057  cbVerb = sizeof(wFlags);
1058  if (RegGetValueW(pEntry->hkClass, wszKey, FlagsName, RRF_RT_REG_DWORD, NULL, &wFlags, &cbVerb) == ERROR_SUCCESS)
1059  {
1060  return wFlags;
1061  }
1062 
1063  return 0;
1064 }
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
#define L(x)
Definition: ntvdm.h:50
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:82
unsigned long DWORD
Definition: ntddk_ex.h:95
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 ( LPCMINVOKECOMMANDINFOEX  lpcmi,
BOOL  bCopy 
)
private

Definition at line 789 of file CDefaultContextMenu.cpp.

790 {
791  if (!m_cidl || !m_pDataObj)
792  return E_FAIL;
793 
794  FORMATETC formatetc;
796  STGMEDIUM medium = {0};
797  medium.tymed = TYMED_HGLOBAL;
798  medium.hGlobal = GlobalAlloc(GHND, sizeof(DWORD));
799  DWORD* pdwFlag = (DWORD*)GlobalLock(medium.hGlobal);
800  if (pdwFlag)
801  *pdwFlag = bCopy ? DROPEFFECT_COPY : DROPEFFECT_MOVE;
802  GlobalUnlock(medium.hGlobal);
803  m_pDataObj->SetData(&formatetc, &medium, TRUE);
804 
806  if (FAILED_UNEXPECTEDLY(hr))
807  return hr;
808 
809  return S_OK;
810 }
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:297
LONG HRESULT
Definition: typedefs.h:79
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:82
unsigned long DWORD
Definition: ntddk_ex.h:95
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
#define S_OK
Definition: intsafe.h:52
CComPtr< IDataObject > m_pDataObj
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190

Referenced by InvokeCommand().

◆ DoCopyToMoveToFolder()

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

Definition at line 861 of file CDefaultContextMenu.cpp.

862 {
863  HRESULT hr = E_FAIL;
864  if (!m_pDataObj)
865  {
866  ERR("m_pDataObj is NULL\n");
867  return hr;
868  }
869 
870  CComPtr<IContextMenu> pContextMenu;
871  if (bCopy)
872  hr = SHCoCreateInstance(NULL, &CLSID_CopyToMenu, NULL,
873  IID_PPV_ARG(IContextMenu, &pContextMenu));
874  else
875  hr = SHCoCreateInstance(NULL, &CLSID_MoveToMenu, NULL,
876  IID_PPV_ARG(IContextMenu, &pContextMenu));
877  if (FAILED_UNEXPECTEDLY(hr))
878  return hr;
879 
881  hr = pContextMenu->QueryInterface(IID_PPV_ARG(IShellExtInit, &pInit));
882  if (FAILED_UNEXPECTEDLY(hr))
883  return hr;
884 
885  hr = pInit->Initialize(m_pidlFolder, m_pDataObj, NULL);
886  if (FAILED_UNEXPECTEDLY(hr))
887  return hr;
888 
889  if (bCopy)
890  lpici->lpVerb = "copyto";
891  else
892  lpici->lpVerb = "moveto";
893 
894  return pContextMenu->InvokeCommand((LPCMINVOKECOMMANDINFO)lpici);
895 }
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
struct IContextMenu::tagCMINVOKECOMMANDINFO * LPCMINVOKECOMMANDINFO
LONG HRESULT
Definition: typedefs.h:79
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:82
#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 ( LPCMINVOKECOMMANDINFOEX  lpcmi)
private

Definition at line 758 of file CDefaultContextMenu.cpp.

759 {
760  if (!m_cidl || !m_pDataObj)
761  return E_FAIL;
762 
764  HRESULT hr = m_psf->CreateViewObject(NULL, IID_PPV_ARG(IDropTarget, &pDT));
765  if (FAILED_UNEXPECTEDLY(hr))
766  return hr;
767 
769 
770  return S_OK;
771 }
#define MK_SHIFT
Definition: winuser.h:2359
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:82
CComPtr< IShellFolder > m_psf
#define S_OK
Definition: intsafe.h:52
CComPtr< IDataObject > m_pDataObj
#define NULL
Definition: types.h:112
#define MK_CONTROL
Definition: winuser.h:2360
BOOL WINAPI SHSimulateDrop(IDropTarget *pDrop, IDataObject *pDataObj, DWORD grfKeyState, PPOINTL lpPt, DWORD *pdwEffect)
Definition: ordinal.c:1821

Referenced by InvokeCommand().

◆ DoCreateNewFolder()

HRESULT CDefaultContextMenu::DoCreateNewFolder ( LPCMINVOKECOMMANDINFOEX  lpici)
private

Definition at line 899 of file CDefaultContextMenu.cpp.

901 {
902  WCHAR wszPath[MAX_PATH];
903  WCHAR wszName[MAX_PATH];
904  WCHAR wszNewFolder[25];
905  HRESULT hr;
906 
907  /* Get folder path */
909  if (FAILED_UNEXPECTEDLY(hr))
910  return hr;
911 
912  if (!LoadStringW(shell32_hInstance, IDS_NEWFOLDER, wszNewFolder, _countof(wszNewFolder)))
913  return E_FAIL;
914 
915  /* Create the name of the new directory */
916  if (!PathYetAnotherMakeUniqueName(wszName, wszPath, NULL, wszNewFolder))
917  return E_FAIL;
918 
919  /* Create the new directory and show the appropriate dialog in case of error */
920  if (SHCreateDirectory(lpici->hwnd, wszName) != ERROR_SUCCESS)
921  return E_FAIL;
922 
923  /* Show and select the new item in the def view */
924  LPITEMIDLIST pidl;
925  PITEMID_CHILD pidlNewItem;
927 
928  /* Notify the view object about the new item */
930 
931  if (!m_site)
932  return S_OK;
933 
934  /* Get a pointer to the shell view */
936  if (FAILED_UNEXPECTEDLY(hr))
937  return S_OK;
938 
939  /* Attempt to get the pidl of the new item */
940  hr = SHILCreateFromPathW(wszName, &pidl, NULL);
941  if (FAILED_UNEXPECTEDLY(hr))
942  return hr;
943 
944  pidlNewItem = ILFindLastID(pidl);
945 
946  hr = psv->SelectItem(pidlNewItem, SVSI_DESELECTOTHERS | SVSI_EDIT | SVSI_ENSUREVISIBLE |
947  SVSI_FOCUSED | SVSI_SELECT);
948  if (FAILED_UNEXPECTEDLY(hr))
949  return hr;
950 
951  SHFree(pidl);
952 
953  return S_OK;
954 }
#define SHCNE_MKDIR
Definition: shlobj.h:1745
#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:82
#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:1777
int WINAPI SHCreateDirectory(HWND hWnd, LPCWSTR path)
Definition: shlfileop.cpp:857
#define S_OK
Definition: intsafe.h:52
#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:326
CONST void * LPCVOID
Definition: windef.h:191
BOOL WINAPI PathYetAnotherMakeUniqueName(LPWSTR buffer, LPCWSTR path, LPCWSTR shortname, LPCWSTR longname)
Definition: shellpath.c:705
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41

Referenced by InvokeCommand().

◆ DoDelete()

HRESULT CDefaultContextMenu::DoDelete ( LPCMINVOKECOMMANDINFOEX  lpcmi)
private

Definition at line 773 of file CDefaultContextMenu.cpp.

774 {
775  if (!m_cidl || !m_pDataObj)
776  return E_FAIL;
777 
780  if (FAILED_UNEXPECTEDLY(hr))
781  return hr;
782 
783  DWORD grfKeyState = (lpcmi->fMask & CMIC_MASK_SHIFT_DOWN) ? MK_SHIFT : 0;
784  SHSimulateDrop(pDT, m_pDataObj, grfKeyState, NULL, NULL);
785 
786  return S_OK;
787 }
#define MK_SHIFT
Definition: winuser.h:2359
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:82
unsigned long DWORD
Definition: ntddk_ex.h:95
HRESULT CRecyclerDropTarget_CreateInstance(REFIID riid, LPVOID *ppvOut)
#define S_OK
Definition: intsafe.h:52
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 ( LPCMINVOKECOMMANDINFOEX  lpcmi)
private

Definition at line 752 of file CDefaultContextMenu.cpp.

753 {
755  return E_FAIL;
756 }
#define E_FAIL
Definition: ddrawi.h:102
#define UNIMPLEMENTED
Definition: debug.h:115

Referenced by InvokeCommand().

◆ DoPaste()

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

Definition at line 699 of file CDefaultContextMenu.cpp.

700 {
701  HRESULT hr;
702 
704  hr = OleGetClipboard(&pda);
705  if (FAILED_UNEXPECTEDLY(hr))
706  return hr;
707 
708  FORMATETC formatetc2;
709  STGMEDIUM medium2;
711 
712  DWORD dwKey= 0;
713 
714  if (SUCCEEDED(pda->GetData(&formatetc2, &medium2)))
715  {
716  DWORD * pdwFlag = (DWORD*)GlobalLock(medium2.hGlobal);
717  if (pdwFlag)
718  {
719  if (*pdwFlag == DROPEFFECT_COPY)
720  dwKey = MK_CONTROL;
721  else
722  dwKey = MK_SHIFT;
723  }
724  else
725  {
726  ERR("No drop effect obtained\n");
727  }
728  GlobalUnlock(medium2.hGlobal);
729  }
730 
731  if (bLink)
732  {
733  dwKey = MK_CONTROL|MK_SHIFT;
734  }
735 
736  CComPtr<IDropTarget> pdrop;
737  if (m_cidl)
738  hr = m_psf->GetUIObjectOf(NULL, 1, &m_apidl[0], IID_NULL_PPV_ARG(IDropTarget, &pdrop));
739  else
740  hr = m_psf->CreateViewObject(NULL, IID_PPV_ARG(IDropTarget, &pdrop));
741 
742  if (FAILED_UNEXPECTEDLY(hr))
743  return hr;
744 
745  SHSimulateDrop(pdrop, pda, dwKey, NULL, NULL);
746 
747  TRACE("CP result %x\n", hr);
748  return S_OK;
749 }
#define MK_SHIFT
Definition: winuser.h:2359
#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:82
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:52
#define NULL
Definition: types.h:112
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
#define MK_CONTROL
Definition: winuser.h:2360
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 ( LPCMINVOKECOMMANDINFOEX  lpcmi)
private

Definition at line 839 of file CDefaultContextMenu.cpp.

841 {
843 
844  // We are asked to run the default property sheet
845  if (hr == S_FALSE)
846  {
848  }
849 
850  return hr;
851 }
HRESULT hr
Definition: shlfolder.c:183
HRESULT WINAPI Shell_DefaultContextMenuCallBack(IShellFolder *psf, IDataObject *pdtobj)
Definition: shlfolder.cpp:462
#define S_FALSE
Definition: winerror.h:2357
#define DFM_INVOKECOMMAND
Definition: precomp.h:45
LONG HRESULT
Definition: typedefs.h:79
#define DFM_CMD_PROPERTIES
Definition: shlobj.h:2464
CComPtr< IShellFolder > m_psf
CComPtr< IDataObject > m_pDataObj
#define NULL
Definition: types.h:112
HRESULT _DoCallback(UINT uMsg, WPARAM wParam, LPVOID lParam)

Referenced by InvokeCommand().

◆ DoRename()

HRESULT CDefaultContextMenu::DoRename ( LPCMINVOKECOMMANDINFOEX  lpcmi)
private

Definition at line 812 of file CDefaultContextMenu.cpp.

813 {
815  HRESULT hr;
816 
817  if (!m_site || !m_cidl)
818  return E_FAIL;
819 
820  /* Get a pointer to the shell browser */
822  if (FAILED_UNEXPECTEDLY(hr))
823  return hr;
824 
825  CComPtr<IShellView> lpSV;
826  hr = psb->QueryActiveShellView(&lpSV);
827  if (FAILED_UNEXPECTEDLY(hr))
828  return hr;
829 
830  SVSIF selFlags = SVSI_DESELECTOTHERS | SVSI_EDIT | SVSI_ENSUREVISIBLE | SVSI_FOCUSED | SVSI_SELECT;
831  hr = lpSV->SelectItem(m_apidl[0], selFlags);
832  if (FAILED_UNEXPECTEDLY(hr))
833  return hr;
834 
835  return S_OK;
836 }
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:82
CComPtr< IUnknown > m_site
#define S_OK
Definition: intsafe.h:52
#define SID_IShellBrowser
PCUITEMID_CHILD_ARRAY m_apidl

Referenced by InvokeCommand().

◆ DoUndo()

HRESULT CDefaultContextMenu::DoUndo ( LPCMINVOKECOMMANDINFOEX  lpcmi)
private

Definition at line 854 of file CDefaultContextMenu.cpp.

855 {
856  ERR("TODO: Undo\n");
857  return E_NOTIMPL;
858 }
#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 356 of file CDefaultContextMenu.cpp.

357 {
358  WCHAR wszName[MAX_PATH], wszBuf[MAX_PATH], *pwszClsid;
359  DWORD cchName;
360  HRESULT hr;
361  HKEY hKey;
362 
363  if (RegOpenKeyExW(hRootKey, L"shellex\\ContextMenuHandlers", 0, KEY_READ, &hKey) != ERROR_SUCCESS)
364  {
365  TRACE("RegOpenKeyExW failed\n");
366  return FALSE;
367  }
368 
369  DWORD dwIndex = 0;
370  while (TRUE)
371  {
372  cchName = _countof(wszName);
373  if (RegEnumKeyExW(hKey, dwIndex++, wszName, &cchName, NULL, NULL, NULL, NULL) != ERROR_SUCCESS)
374  break;
375 
376  /* Key name or key value is CLSID */
377  CLSID clsid;
378  hr = CLSIDFromString(wszName, &clsid);
379  if (hr == S_OK)
380  pwszClsid = wszName;
381  else
382  {
383  DWORD cchBuf = _countof(wszBuf);
384  if (RegGetValueW(hKey, wszName, NULL, RRF_RT_REG_SZ, NULL, wszBuf, &cchBuf) == ERROR_SUCCESS)
385  hr = CLSIDFromString(wszBuf, &clsid);
386  pwszClsid = wszBuf;
387  }
388 
389  if (FAILED(hr))
390  {
391  ERR("CLSIDFromString failed for clsid %S hr 0x%x\n", pwszClsid, hr);
392  continue;
393  }
394 
396  {
398  L"Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved",
399  pwszClsid,
401  NULL,
402  NULL,
403  NULL) != ERROR_SUCCESS)
404  {
405  ERR("Shell extension %s not approved!\n", pwszClsid);
406  continue;
407  }
408  }
409 
411  if (FAILED(hr))
412  WARN("Failed to get context menu entires from shell extension! clsid: %S\n", pwszClsid);
413  }
414 
415  RegCloseKey(hKey);
416  return TRUE;
417 }
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:2753
#define L(x)
Definition: ntvdm.h:50
#define FALSE
Definition: types.h:117
HRESULT LoadDynamicContextMenuHandler(HKEY hKey, REFCLSID clsid)
#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
#define ERR(fmt,...)
Definition: debug.h:110
#define S_OK
Definition: intsafe.h:52
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:3356
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 RegCloseKey(hKey)
Definition: registry.h:47
#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 1283 of file CDefaultContextMenu.cpp.

1289 {
1290  /* We don't handle the help text yet */
1291  if (uFlags == GCS_HELPTEXTA ||
1292  uFlags == GCS_HELPTEXTW ||
1293  HIWORD(idCommand) != 0)
1294  {
1295  return E_NOTIMPL;
1296  }
1297 
1298  UINT CmdId = LOWORD(idCommand);
1299 
1300  if (!m_DynamicEntries.IsEmpty() && CmdId >= m_iIdSHEFirst && CmdId < m_iIdSHELast)
1301  {
1302  idCommand -= m_iIdSHEFirst;
1304  if (!pEntry)
1305  return E_FAIL;
1306 
1307  idCommand -= pEntry->iIdCmdFirst;
1308  return pEntry->pCM->GetCommandString(idCommand,
1309  uFlags,
1310  lpReserved,
1311  lpszName,
1312  uMaxNameLen);
1313  }
1314 
1315  if (!m_StaticEntries.IsEmpty() && CmdId >= m_iIdSCMFirst && CmdId < m_iIdSCMLast)
1316  {
1317  /* Validation just returns S_OK on a match. The id exists. */
1318  if (uFlags == GCS_VALIDATEA || uFlags == GCS_VALIDATEW)
1319  return S_OK;
1320 
1321  CmdId -= m_iIdSCMFirst;
1322 
1323  POSITION it = m_StaticEntries.FindIndex(CmdId);
1324 
1325  if (it == NULL)
1326  return E_INVALIDARG;
1327 
1329 
1330  if (uFlags == GCS_VERBW)
1331  return StringCchCopyW((LPWSTR)lpszName, uMaxNameLen, pEntry->Verb);
1332 
1333  if (uFlags == GCS_VERBA)
1334  {
1335  if (SHUnicodeToAnsi(pEntry->Verb, lpszName, uMaxNameLen))
1336  return S_OK;
1337  }
1338 
1339  return E_INVALIDARG;
1340  }
1341 
1342  //FIXME: Should we handle callbacks here?
1343  if (m_iIdDfltFirst != m_iIdDfltLast && CmdId >= m_iIdDfltFirst && CmdId < m_iIdDfltLast)
1344  {
1345  CmdId -= m_iIdDfltFirst;
1346  /* See the definitions of IDM_CUT and co to see how this works */
1347  CmdId += 0x7000;
1348  }
1349 
1350  /* Loop looking for a matching Id */
1351  for (UINT i = 0; i < _countof(g_StaticInvokeCmdMap); i++)
1352  {
1353  if (g_StaticInvokeCmdMap[i].IntVerb == CmdId)
1354  {
1355  /* Validation just returns S_OK on a match */
1356  if (uFlags == GCS_VALIDATEA || uFlags == GCS_VALIDATEW)
1357  return S_OK;
1358 
1359  /* Return a copy of the ANSI verb */
1360  if (uFlags == GCS_VERBA)
1361  return StringCchCopyA(lpszName, uMaxNameLen, g_StaticInvokeCmdMap[i].szStringVerb);
1362 
1363  /* Convert the ANSI verb to unicode and return that */
1364  if (uFlags == GCS_VERBW)
1365  {
1366  if (SHAnsiToUnicode(g_StaticInvokeCmdMap[i].szStringVerb, (LPWSTR)lpszName, uMaxNameLen))
1367  return S_OK;
1368  }
1369  }
1370  }
1371 
1372  return E_INVALIDARG;
1373 }
struct _StaticInvokeCommandMap_ g_StaticInvokeCmdMap[]
CAtlList< DynamicShellEntry > m_DynamicEntries
UINT uFlags
Definition: api.c:59
#define E_FAIL
Definition: ddrawi.h:102
CAtlList< StaticShellEntry > m_StaticEntries
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:52
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
#define E_NOTIMPL
Definition: ddrawi.h:99
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
#define HIWORD(l)
Definition: typedefs.h:247
WCHAR * LPWSTR
Definition: xmlstorage.h:184
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
#define LOWORD(l)
Definition: pedump.c:82

◆ GetDynamicEntry()

PDynamicShellEntry CDefaultContextMenu::GetDynamicEntry ( UINT  idCmd)
private

Definition at line 956 of file CDefaultContextMenu.cpp.

957 {
958  POSITION it = m_DynamicEntries.GetHeadPosition();
959  while (it != NULL)
960  {
961  DynamicShellEntry& info = m_DynamicEntries.GetNext(it);
962 
963  if (idCmd >= info.iIdCmdFirst + info.NumIds)
964  continue;
965 
966  if (idCmd < info.iIdCmdFirst || idCmd > info.iIdCmdFirst + info.NumIds)
967  return NULL;
968 
969  return &info;
970  }
971 
972  return NULL;
973 }
CAtlList< DynamicShellEntry > m_DynamicEntries
static struct _test_info info[]
Definition: SetCursorPos.c:19
#define NULL
Definition: types.h:112

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

◆ GetSite()

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

Definition at line 1470 of file CDefaultContextMenu.cpp.

1471 {
1472  if (!m_site)
1473  return E_FAIL;
1474 
1475  return m_site->QueryInterface(riid, ppvSite);
1476 }
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 1377 of file CDefaultContextMenu.cpp.

1381 {
1382  /* FIXME: Should we implement this as well? */
1383  return S_OK;
1384 }
#define S_OK
Definition: intsafe.h:52

◆ HandleMenuMsg2()

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

Implements IContextMenu3.

Definition at line 1424 of file CDefaultContextMenu.cpp.

1429 {
1430  if (uMsg == WM_INITMENUPOPUP)
1431  {
1432  POSITION it = m_DynamicEntries.GetHeadPosition();
1433  while (it != NULL)
1434  {
1435  DynamicShellEntry& info = m_DynamicEntries.GetNext(it);
1436  SHForwardContextMenuMsg(info.pCM, uMsg, wParam, lParam, plResult, TRUE);
1437  }
1438  return S_OK;
1439  }
1440 
1441  UINT CmdId;
1442  HRESULT hr = SHGetMenuIdFromMenuMsg(uMsg, lParam, &CmdId);
1443  if (FAILED(hr))
1444  return S_FALSE;
1445 
1446  if (CmdId < m_iIdSHEFirst || CmdId >= m_iIdSHELast)
1447  return S_FALSE;
1448 
1449  CmdId -= m_iIdSHEFirst;
1451  if (pEntry)
1452  {
1453  SHSetMenuIdInMenuMsg(uMsg, lParam, CmdId - pEntry->iIdCmdFirst);
1454  SHForwardContextMenuMsg(pEntry->pCM, uMsg, wParam, lParam, plResult, TRUE);
1455  }
1456 
1457  return S_OK;
1458 }
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:1736
CAtlList< DynamicShellEntry > m_DynamicEntries
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:52
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
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 171 of file CDefaultContextMenu.cpp.

172 {
173  TRACE("cidl %u\n", pdcm->cidl);
174 
175  if (!pdcm->pcmcb && !lpfn)
176  {
177  ERR("CDefaultContextMenu needs a callback!\n");
178  return E_INVALIDARG;
179  }
180 
181  m_cidl = pdcm->cidl;
182  m_apidl = const_cast<PCUITEMID_CHILD_ARRAY>(_ILCopyaPidl(pdcm->apidl, m_cidl));
183  if (m_cidl && !m_apidl)
184  return E_OUTOFMEMORY;
185  m_psf = pdcm->psf;
186  m_pmcb = pdcm->pcmcb;
187  m_pfnmcb = lpfn;
188 
189  m_cKeys = pdcm->cKeys;
190  if (pdcm->cKeys)
191  {
192  m_aKeys = (HKEY*)HeapAlloc(GetProcessHeap(), 0, sizeof(HKEY) * pdcm->cKeys);
193  if (!m_aKeys)
194  return E_OUTOFMEMORY;
195  memcpy(m_aKeys, pdcm->aKeys, sizeof(HKEY) * pdcm->cKeys);
196  }
197 
198  m_psf->GetUIObjectOf(pdcm->hwnd, m_cidl, m_apidl, IID_NULL_PPV_ARG(IDataObject, &m_pDataObj));
199 
200  if (pdcm->pidlFolder)
201  {
203  }
204  else
205  {
207  if (SUCCEEDED(m_psf->QueryInterface(IID_PPV_ARG(IPersistFolder2, &pf))))
208  {
209  if (FAILED(pf->GetCurFolder(&m_pidlFolder)))
210  ERR("GetCurFolder failed\n");
211  }
212  TRACE("pidlFolder %p\n", m_pidlFolder);
213  }
214 
215  return S_OK;
216 }
const HKEY * aKeys
Definition: shlobj.h:2409
IContextMenuCB * pcmcb
Definition: shlobj.h:2402
PIDLIST_ABSOLUTE m_pidlFolder
#define IID_PPV_ARG(Itype, ppType)
IShellFolder * psf
Definition: shlobj.h:2404
#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:736
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:52
CComPtr< IDataObject > m_pDataObj
LPITEMIDLIST WINAPI ILClone(LPCITEMIDLIST pidl)
Definition: pidl.c:228
#define NULL
Definition: types.h:112
HANDLE HKEY
Definition: registry.h:26
CComPtr< IContextMenuCB > m_pmcb
PCUITEMID_CHILD_ARRAY apidl
Definition: shlobj.h:2406
PCIDLIST_ABSOLUTE pidlFolder
Definition: shlobj.h:2403
PITEMID_CHILD * _ILCopyaPidl(PCUITEMID_CHILD_ARRAY apidlsrc, UINT cidl)
Definition: pidl.c:2663
PCUITEMID_CHILD_ARRAY m_apidl

◆ InvokeCommand()

HRESULT WINAPI CDefaultContextMenu::InvokeCommand ( LPCMINVOKECOMMANDINFO  lpcmi)
virtual

Implements IContextMenu.

Definition at line 1175 of file CDefaultContextMenu.cpp.

1177 {
1178  CMINVOKECOMMANDINFOEX LocalInvokeInfo = {};
1179  HRESULT Result;
1180  UINT CmdId;
1181 
1182  /* Take a local copy of the fixed members of the
1183  struct as we might need to modify the verb */
1184  memcpy(&LocalInvokeInfo, lpcmi, min(sizeof(LocalInvokeInfo), lpcmi->cbSize));
1185 
1186  /* Check if this is a string verb */
1187  if (HIWORD(LocalInvokeInfo.lpVerb))
1188  {
1189  /* Get the ID which corresponds to this verb, and update our local copy */
1190  if (MapVerbToCmdId((LPVOID)LocalInvokeInfo.lpVerb, &CmdId, FALSE))
1191  LocalInvokeInfo.lpVerb = MAKEINTRESOURCEA(CmdId);
1192  }
1193 
1194  CmdId = LOWORD(LocalInvokeInfo.lpVerb);
1195 
1196  if (!m_DynamicEntries.IsEmpty() && CmdId >= m_iIdSHEFirst && CmdId < m_iIdSHELast)
1197  {
1198  LocalInvokeInfo.lpVerb -= m_iIdSHEFirst;
1199  Result = InvokeShellExt(&LocalInvokeInfo);
1200  return Result;
1201  }
1202 
1203  if (!m_StaticEntries.IsEmpty() && CmdId >= m_iIdSCMFirst && CmdId < m_iIdSCMLast)
1204  {
1205  LocalInvokeInfo.lpVerb -= m_iIdSCMFirst;
1206  Result = InvokeRegVerb(&LocalInvokeInfo);
1207  return Result;
1208  }
1209 
1210  if (m_iIdCBFirst != m_iIdCBLast && CmdId >= m_iIdCBFirst && CmdId < m_iIdCBLast)
1211  {
1213  return Result;
1214  }
1215 
1216  if (m_iIdDfltFirst != m_iIdDfltLast && CmdId >= m_iIdDfltFirst && CmdId < m_iIdDfltLast)
1217  {
1218  CmdId -= m_iIdDfltFirst;
1219  /* See the definitions of IDM_CUT and co to see how this works */
1220  CmdId += 0x7000;
1221  }
1222 
1223  if (LocalInvokeInfo.cbSize >= sizeof(CMINVOKECOMMANDINFOEX) && (LocalInvokeInfo.fMask & CMIC_MASK_PTINVOKE))
1224  {
1225  if (m_pDataObj && FAILED_UNEXPECTEDLY(DataObject_SetOffset(m_pDataObj, &LocalInvokeInfo.ptInvoke)))
1226  {
1227  ERR("Unable to add OFFSET to DataObject!\n");
1228  }
1229  }
1230 
1231  /* Check if this is a Id */
1232  switch (CmdId)
1233  {
1234  case FCIDM_SHVIEW_INSERT:
1235  Result = DoPaste(&LocalInvokeInfo, FALSE);
1236  break;
1238  Result = DoPaste(&LocalInvokeInfo, TRUE);
1239  break;
1240  case FCIDM_SHVIEW_OPEN:
1241  case FCIDM_SHVIEW_EXPLORE:
1242  Result = DoOpenOrExplore(&LocalInvokeInfo);
1243  break;
1244  case FCIDM_SHVIEW_COPY:
1245  case FCIDM_SHVIEW_CUT:
1246  Result = DoCopyOrCut(&LocalInvokeInfo, CmdId == FCIDM_SHVIEW_COPY);
1247  break;
1249  Result = DoCreateLink(&LocalInvokeInfo);
1250  break;
1251  case FCIDM_SHVIEW_DELETE:
1252  Result = DoDelete(&LocalInvokeInfo);
1253  break;
1254  case FCIDM_SHVIEW_RENAME:
1255  Result = DoRename(&LocalInvokeInfo);
1256  break;
1258  Result = DoProperties(&LocalInvokeInfo);
1259  break;
1261  Result = DoCreateNewFolder(&LocalInvokeInfo);
1262  break;
1263  case FCIDM_SHVIEW_COPYTO:
1264  Result = DoCopyToMoveToFolder(&LocalInvokeInfo, TRUE);
1265  break;
1266  case FCIDM_SHVIEW_MOVETO:
1267  Result = DoCopyToMoveToFolder(&LocalInvokeInfo, FALSE);
1268  break;
1269  case FCIDM_SHVIEW_UNDO:
1270  Result = DoUndo(&LocalInvokeInfo);
1271  break;
1272  default:
1273  Result = E_INVALIDARG;
1274  ERR("Unhandled Verb %xl\n", LOWORD(LocalInvokeInfo.lpVerb));
1275  break;
1276  }
1277 
1278  return Result;
1279 }
#define FCIDM_SHVIEW_UNDO
Definition: shresdef.h:804
HRESULT DoDelete(LPCMINVOKECOMMANDINFOEX lpcmi)
#define TRUE
Definition: types.h:120
#define FCIDM_SHVIEW_OPEN
Definition: shresdef.h:828
#define FCIDM_SHVIEW_COPYTO
Definition: shresdef.h:806
CAtlList< DynamicShellEntry > m_DynamicEntries
HRESULT DoCopyOrCut(LPCMINVOKECOMMANDINFOEX lpcmi, BOOL bCopy)
#define MAKEINTRESOURCEA(i)
Definition: winuser.h:581
#define FCIDM_SHVIEW_PROPERTIES
Definition: shresdef.h:800
CAtlList< StaticShellEntry > m_StaticEntries
#define FCIDM_SHVIEW_INSERTLINK
Definition: shresdef.h:805
#define FALSE
Definition: types.h:117
#define FCIDM_SHVIEW_INSERT
Definition: shresdef.h:803
#define FCIDM_SHVIEW_MOVETO
Definition: shresdef.h:807
#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:824
HRESULT DoCreateNewFolder(LPCMINVOKECOMMANDINFOEX lpici)
#define FCIDM_SHVIEW_EXPLORE
Definition: shresdef.h:827
#define FCIDM_SHVIEW_COPY
Definition: shresdef.h:802
LONG HRESULT
Definition: typedefs.h:79
HRESULT InvokeShellExt(LPCMINVOKECOMMANDINFOEX lpcmi)
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:82
HRESULT DoCreateLink(LPCMINVOKECOMMANDINFOEX lpcmi)
#define FCIDM_SHVIEW_DELETE
Definition: shresdef.h:799
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
HRESULT DoPaste(LPCMINVOKECOMMANDINFOEX lpcmi, BOOL bLink)
#define FCIDM_SHVIEW_CREATELINK
Definition: shresdef.h:822
#define ERR(fmt,...)
Definition: debug.h:110
CComPtr< IDataObject > m_pDataObj
#define FCIDM_SHVIEW_RENAME
Definition: shresdef.h:821
HRESULT DoRename(LPCMINVOKECOMMANDINFOEX lpcmi)
struct IContextMenu::tagCMInvokeCommandInfoEx CMINVOKECOMMANDINFOEX
#define min(a, b)
Definition: monoChain.cc:55
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
HRESULT DoProperties(LPCMINVOKECOMMANDINFOEX lpcmi)
HRESULT DoUndo(LPCMINVOKECOMMANDINFOEX lpcmi)
HRESULT _DoCallback(UINT uMsg, WPARAM wParam, LPVOID lParam)
HRESULT DoOpenOrExplore(LPCMINVOKECOMMANDINFOEX lpcmi)
#define HIWORD(l)
Definition: typedefs.h:247
#define FCIDM_SHVIEW_CUT
Definition: shresdef.h:801
BOOL MapVerbToCmdId(PVOID Verb, PUINT idCmd, BOOL IsUnicode)
HRESULT DoCopyToMoveToFolder(LPCMINVOKECOMMANDINFOEX lpici, BOOL bCopy)
#define LOWORD(l)
Definition: pedump.c:82
HRESULT InvokeRegVerb(LPCMINVOKECOMMANDINFOEX lpcmi)

◆ InvokePidl()

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

Definition at line 1085 of file CDefaultContextMenu.cpp.

1086 {
1087  LPITEMIDLIST pidlFull = ILCombine(m_pidlFolder, pidl);
1088  if (pidlFull == NULL)
1089  {
1090  return E_FAIL;
1091  }
1092 
1093  WCHAR wszPath[MAX_PATH];
1094  BOOL bHasPath = SHGetPathFromIDListW(pidlFull, wszPath);
1095 
1096  WCHAR wszDir[MAX_PATH];
1097  if (bHasPath)
1098  {
1099  wcscpy(wszDir, wszPath);
1100  PathRemoveFileSpec(wszDir);
1101  }
1102  else
1103  {
1105  }
1106 
1107  SHELLEXECUTEINFOW sei;
1108  ZeroMemory(&sei, sizeof(sei));
1109  sei.cbSize = sizeof(sei);
1110  sei.hwnd = lpcmi->hwnd;
1111  sei.nShow = SW_SHOWNORMAL;
1112  sei.lpVerb = pEntry->Verb;
1113  sei.lpDirectory = wszDir;
1114  sei.lpIDList = pidlFull;
1115  sei.hkeyClass = pEntry->hkClass;
1117  if (bHasPath)
1118  {
1119  sei.lpFile = wszPath;
1120  }
1121 
1122  ShellExecuteExW(&sei);
1123 
1124  ILFree(pidlFull);
1125 
1126  return S_OK;
1127 }
#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:1670
#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:2335
__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:52
#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 ( LPCMINVOKECOMMANDINFOEX  lpcmi)
private

Definition at line 1130 of file CDefaultContextMenu.cpp.

1132 {
1133  INT iCmd = LOWORD(lpcmi->lpVerb);
1134  HRESULT hr;
1135  UINT i;
1136 
1137  POSITION it = m_StaticEntries.FindIndex(iCmd);
1138 
1139  if (it == NULL)
1140  return E_INVALIDARG;
1141 
1143 
1144  /* Get the browse flags to see if we need to browse */
1146  BOOL bBrowsed = FALSE;
1147 
1148  for (i=0; i < m_cidl; i++)
1149  {
1150  /* Check if we need to browse */
1151  if (wFlags > 0)
1152  {
1153  /* In xp if we have browsed, we don't open any more folders.
1154  * In win7 we browse to the first folder we find and
1155  * open new windows for each of the rest of the folders */
1156  if (bBrowsed)
1157  continue;
1158 
1159  hr = TryToBrowse(lpcmi, m_apidl[i], wFlags);
1160  if (SUCCEEDED(hr))
1161  {
1162  bBrowsed = TRUE;
1163  continue;
1164  }
1165  }
1166 
1167  InvokePidl(lpcmi, m_apidl[i], pEntry);
1168  }
1169 
1170  return S_OK;
1171 }
HRESULT hr
Definition: shlfolder.c:183
#define TRUE
Definition: types.h:120
int32_t INT
Definition: typedefs.h:58
CAtlList< StaticShellEntry > m_StaticEntries
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
HRESULT TryToBrowse(LPCMINVOKECOMMANDINFOEX lpcmi, LPCITEMIDLIST pidl, DWORD wFlags)
if SUCCEEDED(hr)
#define E_INVALIDARG
Definition: ddrawi.h:101
DWORD BrowserFlagsFromVerb(LPCMINVOKECOMMANDINFOEX lpcmi, PStaticShellEntry pEntry)
LONG HRESULT
Definition: typedefs.h:79
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_ DWORD _Out_ _In_ WORD wFlags
Definition: wincon.h:531
#define S_OK
Definition: intsafe.h:52
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
HRESULT InvokePidl(LPCMINVOKECOMMANDINFOEX lpcmi, LPCITEMIDLIST pidl, PStaticShellEntry pEntry)
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 ( LPCMINVOKECOMMANDINFOEX  lpcmi)
private

Definition at line 1012 of file CDefaultContextMenu.cpp.

1014 {
1015  TRACE("verb %p first %x last %x\n", lpcmi->lpVerb, m_iIdSHEFirst, m_iIdSHELast);
1016 
1017  UINT idCmd = LOWORD(lpcmi->lpVerb);
1019  if (!pEntry)
1020  return E_FAIL;
1021 
1022  /* invoke the dynamic context menu */
1023  lpcmi->lpVerb = MAKEINTRESOURCEA(idCmd - pEntry->iIdCmdFirst);
1024  return pEntry->pCM->InvokeCommand((LPCMINVOKECOMMANDINFO)lpcmi);
1025 }
#define MAKEINTRESOURCEA(i)
Definition: winuser.h:581
#define E_FAIL
Definition: ddrawi.h:102
struct IContextMenu::tagCMINVOKECOMMANDINFO * LPCMINVOKECOMMANDINFO
#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 ( REFCLSID  clsid)
private

Definition at line 302 of file CDefaultContextMenu.cpp.

303 {
304  POSITION it = m_DynamicEntries.GetHeadPosition();
305  while (it != NULL)
306  {
307  const DynamicShellEntry& info = m_DynamicEntries.GetNext(it);
308  if (info.ClassID == clsid)
309  return TRUE;
310  }
311 
312  return FALSE;
313 }
#define TRUE
Definition: types.h:120
CAtlList< DynamicShellEntry > m_DynamicEntries
#define FALSE
Definition: types.h:117
REFCLSID clsid
Definition: msctf.c:82
#define NULL
Definition: types.h:112

Referenced by LoadDynamicContextMenuHandler().

◆ LoadDynamicContextMenuHandler()

HRESULT CDefaultContextMenu::LoadDynamicContextMenuHandler ( HKEY  hKey,
REFCLSID  clsid 
)
private

Definition at line 316 of file CDefaultContextMenu.cpp.

317 {
318  HRESULT hr;
319  TRACE("LoadDynamicContextMenuHandler entered with This %p hKey %p pclsid %s\n", this, hKey, wine_dbgstr_guid(&clsid));
320 
322  return S_OK;
323 
326  if (FAILED(hr))
327  {
328  ERR("SHCoCreateInstance(IContextMenu) failed.clsid %s hr 0x%x\n", wine_dbgstr_guid(&clsid), hr);
329  return hr;
330  }
331 
332  CComPtr<IShellExtInit> pExtInit;
333  hr = pcm->QueryInterface(IID_PPV_ARG(IShellExtInit, &pExtInit));
334  if (FAILED(hr))
335  {
336  ERR("IContextMenu->QueryInterface(IShellExtInit) failed.clsid %s hr 0x%x\n", wine_dbgstr_guid(&clsid), hr);
337  return hr;
338  }
339 
340  hr = pExtInit->Initialize(m_pidlFolder, m_pDataObj, hKey);
341  if (FAILED(hr))
342  {
343  WARN("IShellExtInit::Initialize failed.clsid %s hr 0x%x\n", wine_dbgstr_guid(&clsid), hr);
344  return hr;
345  }
346 
347  if (m_site)
348  IUnknown_SetSite(pcm, m_site);
349 
350  m_DynamicEntries.AddTail({ 0, 0, clsid, pcm });
351 
352  return S_OK;
353 }
HRESULT hr
Definition: shlfolder.c:183
#define WARN(fmt,...)
Definition: debug.h:112
BOOL IsShellExtensionAlreadyLoaded(REFCLSID clsid)
CAtlList< DynamicShellEntry > m_DynamicEntries
PIDLIST_ABSOLUTE m_pidlFolder
const char * wine_dbgstr_guid(const GUID *guid)
#define IID_PPV_ARG(Itype, ppType)
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
LONG HRESULT
Definition: typedefs.h:79
REFCLSID clsid
Definition: msctf.c:82
CComPtr< IUnknown > m_site
#define ERR(fmt,...)
Definition: debug.h:110
#define S_OK
Definition: intsafe.h:52
CComPtr< IDataObject > m_pDataObj
FxAutoRegKey hKey
#define NULL
Definition: types.h:112

Referenced by EnumerateDynamicContextHandlerForKey().

◆ MapVerbToCmdId()

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

Definition at line 979 of file CDefaultContextMenu.cpp.

980 {
981  WCHAR UnicodeStr[MAX_VERB];
982 
983  /* Loop through all the static verbs looking for a match */
984  for (UINT i = 0; i < _countof(g_StaticInvokeCmdMap); i++)
985  {
986  /* We can match both ANSI and unicode strings */
987  if (IsUnicode)
988  {
989  /* The static verbs are ANSI, get a unicode version before doing the compare */
990  SHAnsiToUnicode(g_StaticInvokeCmdMap[i].szStringVerb, UnicodeStr, MAX_VERB);
991  if (!wcscmp(UnicodeStr, (LPWSTR)Verb))
992  {
993  /* Return the Corresponding Id */
994  *idCmd = g_StaticInvokeCmdMap[i].IntVerb;
995  return TRUE;
996  }
997  }
998  else
999  {
1000  if (!strcmp(g_StaticInvokeCmdMap[i].szStringVerb, (LPSTR)Verb))
1001  {
1002  *idCmd = g_StaticInvokeCmdMap[i].IntVerb;
1003  return TRUE;
1004  }
1005  }
1006  }
1007 
1008  return FALSE;
1009 }
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 612 of file CDefaultContextMenu.cpp.

618 {
619  HRESULT hr;
620  UINT idCmdNext = idCmdFirst;
621  UINT cIds = 0;
622 
623  TRACE("BuildShellItemContextMenu entered\n");
624 
625  /* Load static verbs and shell extensions from registry */
626  for (UINT i = 0; i < m_cKeys; i++)
627  {
630  }
631 
632  /* Add static context menu handlers */
633  cIds = AddStaticContextMenusToMenu(hMenu, &IndexMenu, idCmdFirst, idCmdLast);
634  m_iIdSCMFirst = 0;
635  m_iIdSCMLast = cIds;
636  idCmdNext = idCmdFirst + cIds;
637 
638  /* Add dynamic context menu handlers */
639  cIds += AddShellExtensionsToMenu(hMenu, &IndexMenu, idCmdNext, idCmdLast);
641  m_iIdSHELast = cIds;
642  idCmdNext = idCmdFirst + cIds;
643  TRACE("SH_LoadContextMenuHandlers first %x last %x\n", m_iIdSHEFirst, m_iIdSHELast);
644 
645  /* Now let the callback add its own items */
646  QCMINFO qcminfo = {hMenu, IndexMenu, idCmdNext, idCmdLast, NULL};
648  {
649  UINT added = qcminfo.idCmdFirst - idCmdNext;
650  cIds += added;
651  IndexMenu += added;
653  m_iIdCBLast = cIds;
654  idCmdNext = idCmdFirst + cIds;
655  }
656 
657  if (uFlags & CMF_VERBSONLY)
658  return MAKE_HRESULT(SEVERITY_SUCCESS, 0, cIds);
659 
660  /* If this is a background context menu we are done */
661  if (!m_cidl)
662  return MAKE_HRESULT(SEVERITY_SUCCESS, 0, cIds);
663 
664  /* Get the attributes of the items */
665  SFGAOF rfg = SFGAO_BROWSABLE | SFGAO_CANCOPY | SFGAO_CANLINK | SFGAO_CANMOVE | SFGAO_CANDELETE | SFGAO_CANRENAME | SFGAO_HASPROPSHEET | SFGAO_FILESYSTEM | SFGAO_FOLDER;
666  hr = m_psf->GetAttributesOf(m_cidl, m_apidl, &rfg);
667  if (FAILED_UNEXPECTEDLY(hr))
668  return MAKE_HRESULT(SEVERITY_SUCCESS, 0, cIds);
669 
670  /* Add the default part of the menu */
671  HMENU hmenuDefault = LoadMenu(_AtlBaseModule.GetResourceInstance(), L"MENU_SHV_FILE");
672 
673  /* Remove uneeded entries */
674  if (!(rfg & SFGAO_CANMOVE))
675  DeleteMenu(hmenuDefault, IDM_CUT, MF_BYCOMMAND);
676  if (!(rfg & SFGAO_CANCOPY))
677  DeleteMenu(hmenuDefault, IDM_COPY, MF_BYCOMMAND);
678  if (!((rfg & SFGAO_FILESYSTEM) && HasClipboardData()))
679  DeleteMenu(hmenuDefault, IDM_INSERT, MF_BYCOMMAND);
680  if (!(rfg & SFGAO_CANLINK))
681  DeleteMenu(hmenuDefault, IDM_CREATELINK, MF_BYCOMMAND);
682  if (!(rfg & SFGAO_CANDELETE))
683  DeleteMenu(hmenuDefault, IDM_DELETE, MF_BYCOMMAND);
684  if (!(rfg & SFGAO_CANRENAME))
685  DeleteMenu(hmenuDefault, IDM_RENAME, MF_BYCOMMAND);
686  if (!(rfg & SFGAO_HASPROPSHEET))
687  DeleteMenu(hmenuDefault, IDM_PROPERTIES, MF_BYCOMMAND);
688 
689  UINT idMax = Shell_MergeMenus(hMenu, GetSubMenu(hmenuDefault, 0), IndexMenu, idCmdNext, idCmdLast, 0);
690  m_iIdDfltFirst = cIds;
691  cIds += idMax - idCmdNext;
692  m_iIdDfltLast = cIds;
693 
694  DestroyMenu(hmenuDefault);
695 
696  return MAKE_HRESULT(SEVERITY_SUCCESS, 0, cIds);
697 }
#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:856
HRESULT hr
Definition: shlfolder.c:183
#define IDM_RENAME
Definition: shresdef.h:842
UINT uFlags
Definition: api.c:59
#define IDM_COPY
Definition: shresdef.h:838
#define SEVERITY_SUCCESS
Definition: winerror.h:64
#define L(x)
Definition: ntvdm.h:50
if SUCCEEDED(hr)
#define MAKE_HRESULT(sev, fac, code)
Definition: dmerror.h:30
#define IDM_DELETE
Definition: shresdef.h:841
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:82
#define DFM_MERGECONTEXTMENU
Definition: precomp.h:44
#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:5807
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:837
HRESULT _DoCallback(UINT uMsg, WPARAM wParam, LPVOID lParam)
UINT AddShellExtensionsToMenu(HMENU hMenu, UINT *pIndexMenu, UINT idCmdFirst, UINT idCmdLast)
#define IDM_CREATELINK
Definition: shresdef.h:840
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:839
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 1462 of file CDefaultContextMenu.cpp.

1463 {
1464  m_site = pUnkSite;
1465  return S_OK;
1466 }
CComPtr< IUnknown > m_site
#define S_OK
Definition: intsafe.h:52

◆ TryToBrowse()

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

Definition at line 1067 of file CDefaultContextMenu.cpp.

1069 {
1071  HRESULT hr;
1072 
1073  if (!m_site)
1074  return E_FAIL;
1075 
1076  /* Get a pointer to the shell browser */
1078  if (FAILED_UNEXPECTEDLY(hr))
1079  return 0;
1080 
1081  return psb->BrowseObject(ILCombine(m_pidlFolder, pidl), wFlags);
1082 }
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:82
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 66 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 69 of file CDefaultContextMenu.cpp.

Referenced by EnumerateDynamicContextHandlerForKey().

◆ m_cidl

UINT CDefaultContextMenu::m_cidl
private

◆ m_cKeys

UINT CDefaultContextMenu::m_cKeys
private

Definition at line 67 of file CDefaultContextMenu.cpp.

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

◆ m_DynamicEntries

◆ m_iIdCBFirst

UINT CDefaultContextMenu::m_iIdCBFirst
private

Definition at line 76 of file CDefaultContextMenu.cpp.

Referenced by InvokeCommand(), and QueryContextMenu().

◆ m_iIdCBLast

UINT CDefaultContextMenu::m_iIdCBLast
private

Definition at line 77 of file CDefaultContextMenu.cpp.

Referenced by InvokeCommand(), and QueryContextMenu().

◆ m_iIdDfltFirst

UINT CDefaultContextMenu::m_iIdDfltFirst
private

Definition at line 78 of file CDefaultContextMenu.cpp.

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

◆ m_iIdDfltLast

UINT CDefaultContextMenu::m_iIdDfltLast
private

Definition at line 79 of file CDefaultContextMenu.cpp.

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

◆ m_iIdSCMFirst

UINT CDefaultContextMenu::m_iIdSCMFirst
private

Definition at line 74 of file CDefaultContextMenu.cpp.

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

◆ m_iIdSCMLast

UINT CDefaultContextMenu::m_iIdSCMLast
private

Definition at line 75 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

◆ m_pfnmcb

LPFNDFMCALLBACK CDefaultContextMenu::m_pfnmcb
private

Definition at line 62 of file CDefaultContextMenu.cpp.

Referenced by _DoCallback(), and Initialize().

◆ m_pidlFolder

◆ m_pmcb

CComPtr<IContextMenuCB> CDefaultContextMenu::m_pmcb
private

Definition at line 61 of file CDefaultContextMenu.cpp.

Referenced by _DoCallback(), and Initialize().

◆ m_psf

CComPtr<IShellFolder> CDefaultContextMenu::m_psf
private

◆ m_site

CComPtr<IUnknown> CDefaultContextMenu::m_site
private

◆ m_StaticEntries


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