ReactOS  0.4.14-dev-1034-g1e60116
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 DoCreateNewFolder (LPCMINVOKECOMMANDINFO lpici)
 
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 62 of file CDefaultContextMenu.cpp.

Constructor & Destructor Documentation

◆ CDefaultContextMenu()

CDefaultContextMenu::CDefaultContextMenu ( )

Definition at line 142 of file CDefaultContextMenu.cpp.

142  :
143  m_psf(NULL),
144  m_pmcb(NULL),
145  m_pfnmcb(NULL),
146  m_cidl(0),
147  m_apidl(NULL),
148  m_pDataObj(NULL),
149  m_aKeys(NULL),
150  m_cKeys(NULL),
154  m_iIdSHEFirst(0),
155  m_iIdSHELast(0),
157  m_iIdSCMFirst(0),
158  m_iIdSCMLast(0),
159  m_iIdCBFirst(0),
160  m_iIdCBLast(0),
161  m_iIdDfltFirst(0),
162  m_iIdDfltLast(0)
163 
164 {
165 }
PIDLIST_ABSOLUTE m_pidlFolder
smooth NULL
Definition: ftsmooth.c:416
CComPtr< IShellFolder > m_psf
CComPtr< IDataObject > m_pDataObj
PDynamicShellEntry m_pDynamicEntries
CComPtr< IContextMenuCB > m_pmcb
PStaticShellEntry m_pStaticEntries
PCUITEMID_CHILD_ARRAY m_apidl

◆ ~CDefaultContextMenu()

CDefaultContextMenu::~CDefaultContextMenu ( )

Definition at line 167 of file CDefaultContextMenu.cpp.

168 {
169  /* Free dynamic shell extension entries */
170  PDynamicShellEntry pDynamicEntry = m_pDynamicEntries, pNextDynamic;
171  while (pDynamicEntry)
172  {
173  pNextDynamic = pDynamicEntry->pNext;
174  pDynamicEntry->pCM->Release();
175  HeapFree(GetProcessHeap(), 0, pDynamicEntry);
176  pDynamicEntry = pNextDynamic;
177  }
178 
179  /* Free static shell extension entries */
180  PStaticShellEntry pStaticEntry = m_pStaticEntries, pNextStatic;
181  while (pStaticEntry)
182  {
183  pNextStatic = pStaticEntry->pNext;
184  HeapFree(GetProcessHeap(), 0, pStaticEntry->szVerb);
185  HeapFree(GetProcessHeap(), 0, pStaticEntry);
186  pStaticEntry = pNextStatic;
187  }
188 
189  for (UINT i = 0; i < m_cKeys; i++)
192 
193  if (m_pidlFolder)
195  _ILFreeaPidl(const_cast<PITEMID_CHILD *>(m_apidl), m_cidl);
196 }
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:420
PIDLIST_ABSOLUTE m_pidlFolder
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
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
ULONG Release()
#define GetProcessHeap()
Definition: compat.h:403
struct _DynamicShellEntry_ * pNext
void _ILFreeaPidl(LPITEMIDLIST *apidl, UINT cidl)
Definition: pidl.c:2621
PDynamicShellEntry m_pDynamicEntries
struct _StaticShellEntry_ * pNext
unsigned int UINT
Definition: ndis.h:50
PStaticShellEntry m_pStaticEntries
#define HeapFree(x, y, z)
Definition: compat.h:402
PCUITEMID_CHILD_ARRAY m_apidl

Member Function Documentation

◆ _DoCallback()

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

Definition at line 245 of file CDefaultContextMenu.cpp.

246 {
247  if (m_pmcb)
248  {
249  return m_pmcb->CallBack(m_psf, NULL, m_pDataObj, uMsg, wParam, (LPARAM)lParam);
250  }
251  else if(m_pfnmcb)
252  {
253  return m_pfnmcb(m_psf, NULL, m_pDataObj, uMsg, wParam, (LPARAM)lParam);
254  }
255 
256  return E_FAIL;
257 }
#define E_FAIL
Definition: ddrawi.h:102
WPARAM wParam
Definition: combotst.c:138
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
CComPtr< IShellFolder > m_psf
CComPtr< IDataObject > m_pDataObj
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 481 of file CDefaultContextMenu.cpp.

482 {
483  UINT cIds = 0;
484 
485  if (!m_pDynamicEntries)
486  return cIds;
487 
489  do
490  {
491  HRESULT hr = pEntry->pCM->QueryContextMenu(hMenu, *pIndexMenu, idCmdFirst + cIds, idCmdLast, CMF_NORMAL);
492  if (SUCCEEDED(hr))
493  {
494  pEntry->iIdCmdFirst = cIds;
495  pEntry->NumIds = LOWORD(hr);
496  (*pIndexMenu) += pEntry->NumIds;
497 
498  cIds += pEntry->NumIds;
499  if(idCmdFirst + cIds >= idCmdLast)
500  break;
501  }
502  TRACE("pEntry %p hr %x contextmenu %p cmdfirst %x num ids %x\n", pEntry, hr, pEntry->pCM, pEntry->iIdCmdFirst, pEntry->NumIds);
503  pEntry = pEntry->pNext;
504  } while (pEntry);
505 
506  return cIds;
507 }
HRESULT QueryContextMenu([in] HMENU hmenu, [in] UINT indexMenu, [in] UINT idCmdFirst, [in] UINT idCmdLast, [in] UINT uFlags)
HRESULT hr
Definition: shlfolder.c:183
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:78
struct _DynamicShellEntry_ * pNext
PDynamicShellEntry m_pDynamicEntries
unsigned int UINT
Definition: ndis.h:50
#define LOWORD(l)
Definition: pedump.c:82
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by QueryContextMenu().

◆ AddStaticContextMenusToMenu()

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

Definition at line 510 of file CDefaultContextMenu.cpp.

515 {
516  MENUITEMINFOW mii;
517  UINT idResource;
518  WCHAR wszVerb[40];
519  UINT fState;
520  UINT cIds = 0;
521 
522  mii.cbSize = sizeof(mii);
524  mii.fType = MFT_STRING;
525  mii.dwTypeData = NULL;
526 
528 
529  while (pEntry)
530  {
531  fState = MFS_ENABLED;
532  mii.dwTypeData = NULL;
533 
534  /* set first entry as default */
535  if (pEntry == m_pStaticEntries)
536  fState |= MFS_DEFAULT;
537 
538  if (!wcsicmp(pEntry->szVerb, L"open"))
539  {
540  /* override default when open verb is found */
541  fState |= MFS_DEFAULT;
542  idResource = IDS_OPEN_VERB;
543  }
544  else if (!wcsicmp(pEntry->szVerb, L"explore"))
545  idResource = IDS_EXPLORE_VERB;
546  else if (!wcsicmp(pEntry->szVerb, L"runas"))
547  idResource = IDS_RUNAS_VERB;
548  else if (!wcsicmp(pEntry->szVerb, L"edit"))
549  idResource = IDS_EDIT_VERB;
550  else if (!wcsicmp(pEntry->szVerb, L"find"))
551  idResource = IDS_FIND_VERB;
552  else if (!wcsicmp(pEntry->szVerb, L"print"))
553  idResource = IDS_PRINT_VERB;
554  else if (!wcsicmp(pEntry->szVerb, L"printto"))
555  {
556  pEntry = pEntry->pNext;
557  continue;
558  }
559  else
560  idResource = 0;
561 
562  /* By default use verb for menu item name */
563  mii.dwTypeData = pEntry->szVerb;
564 
565  WCHAR wszKey[256];
566  HRESULT hr;
567  hr = StringCbPrintfW(wszKey, sizeof(wszKey), L"shell\\%s", pEntry->szVerb);
568  if (FAILED_UNEXPECTEDLY(hr))
569  {
570  pEntry = pEntry->pNext;
571  continue;
572  }
573 
574  BOOL Extended = FALSE;
575  HKEY hkVerb;
576  if (idResource > 0)
577  {
578  if (LoadStringW(shell32_hInstance, idResource, wszVerb, _countof(wszVerb)))
579  mii.dwTypeData = wszVerb; /* use translated verb */
580  else
581  ERR("Failed to load string\n");
582 
583  LONG res = RegOpenKeyW(pEntry->hkClass, wszKey, &hkVerb);
584  if (res == ERROR_SUCCESS)
585  {
586  res = RegQueryValueExW(hkVerb, L"Extended", NULL, NULL, NULL, NULL);
587  Extended = (res == ERROR_SUCCESS);
588 
589  RegCloseKey(hkVerb);
590  }
591  }
592  else
593  {
594  LONG res = RegOpenKeyW(pEntry->hkClass, wszKey, &hkVerb);
595  if (res == ERROR_SUCCESS)
596  {
597  DWORD cbVerb = sizeof(wszVerb);
598  res = RegLoadMUIStringW(hkVerb, NULL, wszVerb, cbVerb, NULL, 0, NULL);
599  if (res == ERROR_SUCCESS)
600  {
601  /* use description for the menu entry */
602  mii.dwTypeData = wszVerb;
603  }
604 
605  res = RegQueryValueExW(hkVerb, L"Extended", NULL, NULL, NULL, NULL);
606  Extended = (res == ERROR_SUCCESS);
607 
608  RegCloseKey(hkVerb);
609  }
610  }
611 
612  if (!Extended || GetAsyncKeyState(VK_SHIFT) < 0)
613  {
614  mii.cch = wcslen(mii.dwTypeData);
615  mii.fState = fState;
616  mii.wID = iIdCmdFirst + cIds;
617  InsertMenuItemW(hMenu, *pIndexMenu, TRUE, &mii);
618  (*pIndexMenu)++;
619  cIds++;
620  }
621 
622  pEntry = pEntry->pNext;
623 
624  if (mii.wID >= iIdCmdLast)
625  break;
626  }
627 
628  return cIds;
629 }
#define MFT_STRING
Definition: winuser.h:741
#define TRUE
Definition: types.h:120
#define IDS_FIND_VERB
Definition: shresdef.h:201
#define ERROR_SUCCESS
Definition: deptool.c:10
HRESULT hr
Definition: shlfolder.c:183
#define _countof(array)
Definition: fontsub.cpp:30
LPWSTR dwTypeData
Definition: winuser.h:3244
#define IDS_OPEN_VERB
Definition: shresdef.h:197
#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:199
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define MFS_ENABLED
Definition: winuser.h:745
HINSTANCE shell32_hInstance
Definition: misc.cpp:82
#define IDS_EXPLORE_VERB
Definition: shresdef.h:198
#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
smooth NULL
Definition: ftsmooth.c:416
#define IDS_PRINT_VERB
Definition: shresdef.h:202
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:200
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:78
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
#define MIIM_TYPE
Definition: winuser.h:720
SHORT WINAPI GetAsyncKeyState(_In_ int)
#define wcsicmp
Definition: string.h:1152
#define ERR(fmt,...)
Definition: debug.h:109
struct _StaticShellEntry_ * pNext
BOOL WINAPI InsertMenuItemW(_In_ HMENU, _In_ UINT, _In_ BOOL, _In_ LPCMENUITEMINFOW)
unsigned int UINT
Definition: ndis.h:50
GLuint res
Definition: glext.h:9613
#define MIIM_DATA
Definition: winuser.h:721
PStaticShellEntry m_pStaticEntries
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

Referenced by QueryContextMenu().

◆ AddStaticEntriesForKey()

void CDefaultContextMenu::AddStaticEntriesForKey ( HKEY  hKey)
private

Definition at line 297 of file CDefaultContextMenu.cpp.

298 {
299  WCHAR wszName[40];
300  DWORD cchName, dwIndex = 0;
301  HKEY hShellKey;
302 
303  LRESULT lres = RegOpenKeyExW(hKey, L"shell", 0, KEY_READ, &hShellKey);
304  if (lres != STATUS_SUCCESS)
305  return;
306 
307  while(TRUE)
308  {
309  cchName = _countof(wszName);
310  if (RegEnumKeyExW(hShellKey, dwIndex++, wszName, &cchName, NULL, NULL, NULL, NULL) != ERROR_SUCCESS)
311  break;
312 
313  AddStaticEntry(hKey, wszName);
314  }
315 
316  RegCloseKey(hShellKey);
317 }
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
#define _countof(array)
Definition: fontsub.cpp:30
_In_ PSID _Out_writes_to_opt_ cchName LPSTR _Inout_ LPDWORD cchName
Definition: winbase.h:2723
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
void AddStaticEntry(const HKEY hkeyClass, const WCHAR *szVerb)
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
LONG_PTR LRESULT
Definition: windef.h:209
return STATUS_SUCCESS
Definition: btrfs.c:2938

Referenced by QueryContextMenu().

◆ AddStaticEntry()

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

Definition at line 259 of file CDefaultContextMenu.cpp.

260 {
261  PStaticShellEntry pEntry = m_pStaticEntries, pLastEntry = NULL;
262  while(pEntry)
263  {
264  if (!wcsicmp(pEntry->szVerb, szVerb))
265  {
266  /* entry already exists */
267  return;
268  }
269  pLastEntry = pEntry;
270  pEntry = pEntry->pNext;
271  }
272 
273  TRACE("adding verb %s\n", debugstr_w(szVerb));
274 
275  pEntry = (StaticShellEntry *)HeapAlloc(GetProcessHeap(), 0, sizeof(StaticShellEntry));
276  if (pEntry)
277  {
278  pEntry->pNext = NULL;
279  pEntry->szVerb = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, (wcslen(szVerb) + 1) * sizeof(WCHAR));
280  if (pEntry->szVerb)
281  wcscpy(pEntry->szVerb, szVerb);
282  pEntry->hkClass = hkeyClass;
283  }
284 
285  if (!wcsicmp(szVerb, L"open"))
286  {
287  /* open verb is always inserted in front */
288  pEntry->pNext = m_pStaticEntries;
289  m_pStaticEntries = pEntry;
290  }
291  else if (pLastEntry)
292  pLastEntry->pNext = pEntry;
293  else
294  m_pStaticEntries = pEntry;
295 }
struct _StaticShellEntry_ StaticShellEntry
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
_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 wcsicmp
Definition: string.h:1152
struct _StaticShellEntry_ * pNext
WCHAR * LPWSTR
Definition: xmlstorage.h:184
PStaticShellEntry m_pStaticEntries
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

Referenced by AddStaticEntriesForKey().

◆ BrowserFlagsFromVerb()

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

Definition at line 1032 of file CDefaultContextMenu.cpp.

1033 {
1035  HWND hwndTree;
1036  LPCWSTR FlagsName;
1037  WCHAR wszKey[256];
1038  HRESULT hr;
1039  DWORD wFlags;
1040  DWORD cbVerb;
1041 
1042  if (!m_site)
1043  return 0;
1044 
1045  /* Get a pointer to the shell browser */
1047  if (FAILED_UNEXPECTEDLY(hr))
1048  return 0;
1049 
1050  /* See if we are in Explore or Browse mode. If the browser's tree is present, we are in Explore mode.*/
1051  if (SUCCEEDED(psb->GetControlWindow(FCW_TREE, &hwndTree)) && hwndTree)
1052  FlagsName = L"ExplorerFlags";
1053  else
1054  FlagsName = L"BrowserFlags";
1055 
1056  /* Try to get the flag from the verb */
1057  hr = StringCbPrintfW(wszKey, sizeof(wszKey), L"shell\\%s", pEntry->szVerb);
1058  if (FAILED_UNEXPECTEDLY(hr))
1059  return 0;
1060 
1061  cbVerb = sizeof(wFlags);
1062  if (RegGetValueW(pEntry->hkClass, wszKey, FlagsName, RRF_RT_REG_DWORD, NULL, &wFlags, &cbVerb) == ERROR_SUCCESS)
1063  {
1064  return wFlags;
1065  }
1066 
1067  return 0;
1068 }
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:1448
smooth NULL
Definition: ftsmooth.c:416
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:78
#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:534
#define SID_IShellBrowser
#define RRF_RT_REG_DWORD
Definition: driver.c:578
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by InvokeRegVerb().

◆ DoCopyOrCut()

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

Definition at line 846 of file CDefaultContextMenu.cpp.

847 {
848  if (!m_cidl || !m_pDataObj)
849  return E_FAIL;
850 
851  FORMATETC formatetc;
853  STGMEDIUM medium = {0};
854  medium.tymed = TYMED_HGLOBAL;
855  medium.hGlobal = GlobalAlloc(GHND, sizeof(DWORD));
856  DWORD* pdwFlag = (DWORD*)GlobalLock(medium.hGlobal);
857  if (pdwFlag)
858  *pdwFlag = bCopy ? DROPEFFECT_COPY : DROPEFFECT_MOVE;
859  GlobalUnlock(medium.hGlobal);
860  m_pDataObj->SetData(&formatetc, &medium, TRUE);
861 
863  if (FAILED_UNEXPECTEDLY(hr))
864  return hr;
865 
866  return S_OK;
867 }
HRESULT WINAPI OleSetClipboard(IDataObject *data)
Definition: clipboard.c:2199
#define TRUE
Definition: types.h:120
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
UINT WINAPI RegisterClipboardFormatW(_In_ LPCWSTR)
#define E_FAIL
Definition: ddrawi.h:102
#define GHND
Definition: winbase.h:294
LONG HRESULT
Definition: typedefs.h:78
#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:59
CComPtr< IDataObject > m_pDataObj
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190

Referenced by InvokeCommand().

◆ DoCreateLink()

HRESULT CDefaultContextMenu::DoCreateLink ( LPCMINVOKECOMMANDINFO  lpcmi)
private

Definition at line 816 of file CDefaultContextMenu.cpp.

817 {
818  if (!m_cidl || !m_pDataObj)
819  return E_FAIL;
820 
822  HRESULT hr = m_psf->CreateViewObject(NULL, IID_PPV_ARG(IDropTarget, &pDT));
823  if (FAILED_UNEXPECTEDLY(hr))
824  return hr;
825 
827 
828  return S_OK;
829 }
#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
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:78
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
CComPtr< IShellFolder > m_psf
#define S_OK
Definition: intsafe.h:59
CComPtr< IDataObject > m_pDataObj
#define MK_CONTROL
Definition: winuser.h:2345
BOOL WINAPI SHSimulateDrop(IDropTarget *pDrop, IDataObject *pDataObj, DWORD grfKeyState, PPOINTL lpPt, DWORD *pdwEffect)
Definition: ordinal.c:1775

Referenced by InvokeCommand().

◆ DoCreateNewFolder()

HRESULT CDefaultContextMenu::DoCreateNewFolder ( LPCMINVOKECOMMANDINFO  lpici)
private

Definition at line 906 of file CDefaultContextMenu.cpp.

908 {
909  WCHAR wszPath[MAX_PATH];
910  WCHAR wszName[MAX_PATH];
911  WCHAR wszNewFolder[25];
912  HRESULT hr;
913 
914  /* Get folder path */
916  if (FAILED_UNEXPECTEDLY(hr))
917  return hr;
918 
919  if (!LoadStringW(shell32_hInstance, IDS_NEWFOLDER, wszNewFolder, _countof(wszNewFolder)))
920  return E_FAIL;
921 
922  /* Create the name of the new directory */
923  if (!PathYetAnotherMakeUniqueName(wszName, wszPath, NULL, wszNewFolder))
924  return E_FAIL;
925 
926  /* Create the new directory and show the appropriate dialog in case of error */
927  if (SHCreateDirectory(lpici->hwnd, wszName) != ERROR_SUCCESS)
928  return E_FAIL;
929 
930  /* Show and select the new item in the def view */
931  LPITEMIDLIST pidl;
932  PITEMID_CHILD pidlNewItem;
934 
935  /* Notify the view object about the new item */
937 
938  if (!m_site)
939  return S_OK;
940 
941  /* Get a pointer to the shell view */
943  if (FAILED_UNEXPECTEDLY(hr))
944  return S_OK;
945 
946  /* Attempt to get the pidl of the new item */
947  hr = SHILCreateFromPathW(wszName, &pidl, NULL);
948  if (FAILED_UNEXPECTEDLY(hr))
949  return hr;
950 
951  pidlNewItem = ILFindLastID(pidl);
952 
953  hr = psv->SelectItem(pidlNewItem, SVSI_DESELECTOTHERS | SVSI_EDIT | SVSI_ENSUREVISIBLE |
954  SVSI_FOCUSED | SVSI_SELECT);
955  if (FAILED_UNEXPECTEDLY(hr))
956  return hr;
957 
958  SHFree(pidl);
959 
960  return S_OK;
961 }
#define SHCNE_MKDIR
Definition: shlobj.h:1731
#define IDS_NEWFOLDER
#define ERROR_SUCCESS
Definition: deptool.c:10
HRESULT hr
Definition: shlfolder.c:183
#define _countof(array)
Definition: fontsub.cpp:30
BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath)
Definition: pidl.c:1280
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:1448
HINSTANCE shell32_hInstance
Definition: misc.cpp:82
smooth NULL
Definition: ftsmooth.c:416
LPITEMIDLIST WINAPI ILFindLastID(LPCITEMIDLIST pidl)
Definition: pidl.c:189
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:78
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
#define MAX_PATH
Definition: compat.h:26
void WINAPI SHChangeNotify(LONG wEventId, UINT uFlags, LPCVOID dwItem1, LPCVOID dwItem2)
Definition: changenotify.c:340
CComPtr< IUnknown > m_site
#define SHCNF_PATHW
Definition: shlobj.h:1763
int WINAPI SHCreateDirectory(HWND hWnd, LPCWSTR path)
Definition: shlfileop.cpp:788
#define S_OK
Definition: intsafe.h:59
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 831 of file CDefaultContextMenu.cpp.

832 {
833  if (!m_cidl || !m_pDataObj)
834  return E_FAIL;
835 
838  if (FAILED_UNEXPECTEDLY(hr))
839  return hr;
840 
841  SHSimulateDrop(pDT, m_pDataObj, 0, NULL, NULL);
842 
843  return S_OK;
844 }
HRESULT hr
Definition: shlfolder.c:183
#define IID_PPV_ARG(Itype, ppType)
#define E_FAIL
Definition: ddrawi.h:102
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:78
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
HRESULT CRecyclerDropTarget_CreateInstance(REFIID riid, LPVOID *ppvOut)
#define S_OK
Definition: intsafe.h:59
CComPtr< IDataObject > m_pDataObj
BOOL WINAPI SHSimulateDrop(IDropTarget *pDrop, IDataObject *pDataObj, DWORD grfKeyState, PPOINTL lpPt, DWORD *pdwEffect)
Definition: ordinal.c:1775

Referenced by InvokeCommand().

◆ DoOpenOrExplore()

HRESULT CDefaultContextMenu::DoOpenOrExplore ( LPCMINVOKECOMMANDINFO  lpcmi)
private

Definition at line 810 of file CDefaultContextMenu.cpp.

811 {
813  return E_FAIL;
814 }
#define E_FAIL
Definition: ddrawi.h:102
#define UNIMPLEMENTED
Definition: debug.h:114

Referenced by InvokeCommand().

◆ DoPaste()

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

Definition at line 758 of file CDefaultContextMenu.cpp.

759 {
760  HRESULT hr;
761 
763  hr = OleGetClipboard(&pda);
764  if (FAILED_UNEXPECTEDLY(hr))
765  return hr;
766 
767  FORMATETC formatetc2;
768  STGMEDIUM medium2;
770 
771  DWORD dwKey= 0;
772 
773  if (SUCCEEDED(pda->GetData(&formatetc2, &medium2)))
774  {
775  DWORD * pdwFlag = (DWORD*)GlobalLock(medium2.hGlobal);
776  if (pdwFlag)
777  {
778  if (*pdwFlag == DROPEFFECT_COPY)
779  dwKey = MK_CONTROL;
780  else
781  dwKey = MK_SHIFT;
782  }
783  else {
784  ERR("No drop effect obtained");
785  }
786  GlobalUnlock(medium2.hGlobal);
787  }
788 
789  if (bLink)
790  {
791  dwKey = MK_CONTROL|MK_SHIFT;
792  }
793 
794  CComPtr<IDropTarget> pdrop;
795  if (m_cidl)
796  hr = m_psf->GetUIObjectOf(NULL, 1, &m_apidl[0], IID_NULL_PPV_ARG(IDropTarget, &pdrop));
797  else
798  hr = m_psf->CreateViewObject(NULL, IID_PPV_ARG(IDropTarget, &pdrop));
799 
800  if (FAILED_UNEXPECTEDLY(hr))
801  return hr;
802 
803  SHSimulateDrop(pdrop, pda, dwKey, NULL, NULL);
804 
805  TRACE("CP result %x\n", hr);
806  return S_OK;
807 }
#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
smooth NULL
Definition: ftsmooth.c:416
#define IID_NULL_PPV_ARG(Itype, ppType)
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:78
#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:109
#define S_OK
Definition: intsafe.h:59
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
#define MK_CONTROL
Definition: winuser.h:2345
#define SUCCEEDED(hr)
Definition: intsafe.h:57
PCUITEMID_CHILD_ARRAY m_apidl
BOOL WINAPI SHSimulateDrop(IDropTarget *pDrop, IDataObject *pDataObj, DWORD grfKeyState, PPOINTL lpPt, DWORD *pdwEffect)
Definition: ordinal.c:1775

Referenced by InvokeCommand().

◆ DoProperties()

HRESULT CDefaultContextMenu::DoProperties ( LPCMINVOKECOMMANDINFO  lpcmi)
private

Definition at line 896 of file CDefaultContextMenu.cpp.

898 {
900 
901  return S_OK;
902 }
#define DFM_INVOKECOMMAND
Definition: precomp.h:45
smooth NULL
Definition: ftsmooth.c:416
#define DFM_CMD_PROPERTIES
Definition: shlobj.h:2428
#define S_OK
Definition: intsafe.h:59
HRESULT _DoCallback(UINT uMsg, WPARAM wParam, LPVOID lParam)

Referenced by InvokeCommand().

◆ DoRename()

HRESULT CDefaultContextMenu::DoRename ( LPCMINVOKECOMMANDINFO  lpcmi)
private

Definition at line 869 of file CDefaultContextMenu.cpp.

870 {
872  HRESULT hr;
873 
874  if (!m_site || !m_cidl)
875  return E_FAIL;
876 
877  /* Get a pointer to the shell browser */
879  if (FAILED_UNEXPECTEDLY(hr))
880  return hr;
881 
882  CComPtr<IShellView> lpSV;
883  hr = psb->QueryActiveShellView(&lpSV);
884  if (FAILED_UNEXPECTEDLY(hr))
885  return hr;
886 
887  SVSIF selFlags = SVSI_DESELECTOTHERS | SVSI_EDIT | SVSI_ENSUREVISIBLE | SVSI_FOCUSED | SVSI_SELECT;
888  hr = lpSV->SelectItem(m_apidl[0], selFlags);
889  if (FAILED_UNEXPECTEDLY(hr))
890  return hr;
891 
892  return S_OK;
893 }
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:1448
LONG HRESULT
Definition: typedefs.h:78
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
CComPtr< IUnknown > m_site
#define S_OK
Definition: intsafe.h:59
#define SID_IShellBrowser
PCUITEMID_CHILD_ARRAY m_apidl

Referenced by InvokeCommand().

◆ EnumerateDynamicContextHandlerForKey()

BOOL CDefaultContextMenu::EnumerateDynamicContextHandlerForKey ( HKEY  hRootKey)
private

Definition at line 417 of file CDefaultContextMenu.cpp.

418 {
419  WCHAR wszName[MAX_PATH], wszBuf[MAX_PATH], *pwszClsid;
420  DWORD cchName;
421  HRESULT hr;
422  HKEY hKey;
423 
424  if (RegOpenKeyExW(hRootKey, L"shellex\\ContextMenuHandlers", 0, KEY_READ, &hKey) != ERROR_SUCCESS)
425  {
426  TRACE("RegOpenKeyExW failed\n");
427  return FALSE;
428  }
429 
430  DWORD dwIndex = 0;
431  while (TRUE)
432  {
433  cchName = _countof(wszName);
434  if (RegEnumKeyExW(hKey, dwIndex++, wszName, &cchName, NULL, NULL, NULL, NULL) != ERROR_SUCCESS)
435  break;
436 
437  /* Key name or key value is CLSID */
438  CLSID clsid;
439  hr = CLSIDFromString(wszName, &clsid);
440  if (hr == S_OK)
441  pwszClsid = wszName;
442  else
443  {
444  DWORD cchBuf = _countof(wszBuf);
445  if (RegGetValueW(hKey, wszName, NULL, RRF_RT_REG_SZ, NULL, wszBuf, &cchBuf) == ERROR_SUCCESS)
446  hr = CLSIDFromString(wszBuf, &clsid);
447  pwszClsid = wszBuf;
448  }
449 
450  if (FAILED(hr))
451  {
452  ERR("CLSIDFromString failed for clsid %S hr 0x%x\n", pwszClsid, hr);
453  continue;
454  }
455 
457  {
459  L"Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved",
460  pwszClsid,
462  NULL,
463  NULL,
464  NULL) != ERROR_SUCCESS)
465  {
466  ERR("Shell extension %s not approved!\n", pwszClsid);
467  continue;
468  }
469  }
470 
472  if (FAILED(hr))
473  WARN("Failed to get context menu entires from shell extension! clsid: %S\n", pwszClsid);
474  }
475 
476  RegCloseKey(hKey);
477  return TRUE;
478 }
LSTATUS WINAPI RegGetValueW(HKEY hKey, LPCWSTR pszSubKey, LPCWSTR pszValue, DWORD dwFlags, LPDWORD pdwType, PVOID pvData, LPDWORD pcbData)
Definition: reg.c:1965
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
HRESULT hr
Definition: shlfolder.c:183
#define KEY_READ
Definition: nt_native.h:1023
#define _countof(array)
Definition: fontsub.cpp:30
#define WARN(fmt,...)
Definition: debug.h:111
#define RRF_RT_REG_SZ
Definition: driver.c:575
_In_ PSID _Out_writes_to_opt_ cchName LPSTR _Inout_ LPDWORD cchName
Definition: winbase.h:2723
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:78
#define MAX_PATH
Definition: compat.h:26
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:109
#define S_OK
Definition: intsafe.h:59
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 1270 of file CDefaultContextMenu.cpp.

1276 {
1277  /* We don't handle the help text yet */
1278  if (uFlags == GCS_HELPTEXTA ||
1279  uFlags == GCS_HELPTEXTW ||
1280  HIWORD(idCommand) != 0)
1281  {
1282  return E_NOTIMPL;
1283  }
1284 
1285  UINT CmdId = LOWORD(idCommand);
1286 
1287  if (m_pDynamicEntries && CmdId >= m_iIdSHEFirst && CmdId < m_iIdSHELast)
1288  {
1289  idCommand -= m_iIdSHEFirst;
1290  PDynamicShellEntry pEntry = GetDynamicEntry(idCommand);
1291  if (!pEntry)
1292  return E_FAIL;
1293 
1294  idCommand -= pEntry->iIdCmdFirst;
1295  return pEntry->pCM->GetCommandString(idCommand,
1296  uFlags,
1297  lpReserved,
1298  lpszName,
1299  uMaxNameLen);
1300  }
1301 
1302  if (m_pStaticEntries && CmdId >= m_iIdSCMFirst && CmdId < m_iIdSCMLast)
1303  {
1304  /* Validation just returns S_OK on a match. The id exists. */
1305  if (uFlags == GCS_VALIDATEA || uFlags == GCS_VALIDATEW)
1306  return S_OK;
1307 
1308  CmdId -= m_iIdSCMFirst;
1309 
1311  while (pEntry && (CmdId--) > 0)
1312  pEntry = pEntry->pNext;
1313 
1314  if (!pEntry)
1315  return E_INVALIDARG;
1316 
1317  if (uFlags == GCS_VERBW)
1318  return StringCchCopyW((LPWSTR)lpszName, uMaxNameLen, pEntry->szVerb);
1319 
1320  if (uFlags == GCS_VERBA)
1321  {
1322  if (SHUnicodeToAnsi(pEntry->szVerb, lpszName, uMaxNameLen))
1323  return S_OK;
1324  }
1325 
1326  return E_INVALIDARG;
1327  }
1328 
1329  //FIXME: Should we handle callbacks here?
1330  if (m_iIdDfltFirst != m_iIdDfltLast && CmdId >= m_iIdDfltFirst && CmdId < m_iIdDfltLast)
1331  {
1332  CmdId -= m_iIdDfltFirst;
1333  /* See the definitions of IDM_CUT and co to see how this works */
1334  CmdId += 0x7000;
1335  }
1336 
1337  /* Loop looking for a matching Id */
1338  for (UINT i = 0; i < _countof(g_StaticInvokeCmdMap); i++)
1339  {
1340  if (g_StaticInvokeCmdMap[i].IntVerb == CmdId)
1341  {
1342  /* Validation just returns S_OK on a match */
1343  if (uFlags == GCS_VALIDATEA || uFlags == GCS_VALIDATEW)
1344  return S_OK;
1345 
1346  /* Return a copy of the ANSI verb */
1347  if (uFlags == GCS_VERBA)
1348  return StringCchCopyA(lpszName, uMaxNameLen, g_StaticInvokeCmdMap[i].szStringVerb);
1349 
1350  /* Convert the ANSI verb to unicode and return that */
1351  if (uFlags == GCS_VERBW)
1352  {
1353  if (SHAnsiToUnicode(g_StaticInvokeCmdMap[i].szStringVerb, (LPWSTR)lpszName, uMaxNameLen))
1354  return S_OK;
1355  }
1356  }
1357  }
1358 
1359  return E_INVALIDARG;
1360 }
struct _StaticInvokeCommandMap_ g_StaticInvokeCmdMap[]
#define _countof(array)
Definition: fontsub.cpp:30
UINT uFlags
Definition: api.c:59
#define E_FAIL
Definition: ddrawi.h:102
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
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
INT WINAPI SHUnicodeToAnsi(LPCWSTR lpSrcStr, LPSTR lpDstStr, INT iLen)
Definition: string.c:2749
#define E_INVALIDARG
Definition: ddrawi.h:101
HRESULT GetCommandString([in] UINT_PTR idCmd, [in] UINT uType, [out] UINT *pwReserved, [out, size_is(cchMax)] LPSTR pszName, [in] UINT cchMax)
PDynamicShellEntry GetDynamicEntry(UINT idCmd)
STRSAFEAPI StringCchCopyA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPCSTR pszSrc)
Definition: strsafe.h:145
#define S_OK
Definition: intsafe.h:59
PDynamicShellEntry m_pDynamicEntries
#define E_NOTIMPL
Definition: ddrawi.h:99
struct _StaticShellEntry_ * pNext
unsigned int UINT
Definition: ndis.h:50
#define HIWORD(l)
Definition: typedefs.h:247
WCHAR * LPWSTR
Definition: xmlstorage.h:184
DWORD WINAPI SHAnsiToUnicode(LPCSTR lpSrcStr, LPWSTR lpDstStr, int iLen)
Definition: string.c:2625
PStaticShellEntry m_pStaticEntries
#define LOWORD(l)
Definition: pedump.c:82

◆ GetDynamicEntry()

PDynamicShellEntry CDefaultContextMenu::GetDynamicEntry ( UINT  idCmd)
private

Definition at line 963 of file CDefaultContextMenu.cpp.

964 {
966 
967  while(pEntry && idCmd >= pEntry->iIdCmdFirst + pEntry->NumIds)
968  pEntry = pEntry->pNext;
969 
970  if (!pEntry)
971  return NULL;
972 
973  if (idCmd < pEntry->iIdCmdFirst || idCmd > pEntry->iIdCmdFirst + pEntry->NumIds)
974  return NULL;
975 
976  return pEntry;
977 }
smooth NULL
Definition: ftsmooth.c:416
struct _DynamicShellEntry_ * pNext
PDynamicShellEntry m_pDynamicEntries

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

◆ GetSite()

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

Definition at line 1457 of file CDefaultContextMenu.cpp.

1458 {
1459  if (!m_site)
1460  return E_FAIL;
1461 
1462  return m_site->QueryInterface(riid, ppvSite);
1463 }
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 1364 of file CDefaultContextMenu.cpp.

1368 {
1369  /* FIXME: Should we implement this as well? */
1370  return S_OK;
1371 }
#define S_OK
Definition: intsafe.h:59

◆ HandleMenuMsg2()

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

Implements IContextMenu3.

Definition at line 1411 of file CDefaultContextMenu.cpp.

1416 {
1417  if (uMsg == WM_INITMENUPOPUP)
1418  {
1420  while (pEntry)
1421  {
1422  SHForwardContextMenuMsg(pEntry->pCM, uMsg, wParam, lParam, plResult, TRUE);
1423  pEntry = pEntry->pNext;
1424  }
1425  return S_OK;
1426  }
1427 
1428  UINT CmdId;
1429  HRESULT hr = SHGetMenuIdFromMenuMsg(uMsg, lParam, &CmdId);
1430  if (FAILED(hr))
1431  return S_FALSE;
1432 
1433  if (CmdId < m_iIdSHEFirst || CmdId >= m_iIdSHELast)
1434  return S_FALSE;
1435 
1436  CmdId -= m_iIdSHEFirst;
1437  PDynamicShellEntry pEntry = GetDynamicEntry(CmdId);
1438  if (pEntry)
1439  {
1440  SHSetMenuIdInMenuMsg(uMsg, lParam, CmdId - pEntry->iIdCmdFirst);
1441  SHForwardContextMenuMsg(pEntry->pCM, uMsg, wParam, lParam, plResult, TRUE);
1442  }
1443 
1444  return S_OK;
1445 }
HRESULT SHSetMenuIdInMenuMsg(UINT uMsg, LPARAM lParam, UINT CmdId)
#define TRUE
Definition: types.h:120
HRESULT hr
Definition: shlfolder.c:183
#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:78
struct _DynamicShellEntry_ * pNext
PDynamicShellEntry GetDynamicEntry(UINT idCmd)
#define S_OK
Definition: intsafe.h:59
PDynamicShellEntry m_pDynamicEntries
unsigned int UINT
Definition: ndis.h:50
HRESULT SHGetMenuIdFromMenuMsg(UINT uMsg, LPARAM lParam, UINT *CmdId)
LPARAM lParam
Definition: combotst.c:139

◆ Initialize()

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

Definition at line 198 of file CDefaultContextMenu.cpp.

199 {
200  TRACE("cidl %u\n", pdcm->cidl);
201 
202  if (!pdcm->pcmcb && !lpfn)
203  {
204  ERR("CDefaultContextMenu needs a callback!\n");
205  return E_INVALIDARG;
206  }
207 
208  m_cidl = pdcm->cidl;
209  m_apidl = const_cast<PCUITEMID_CHILD_ARRAY>(_ILCopyaPidl(pdcm->apidl, m_cidl));
210  if (m_cidl && !m_apidl)
211  return E_OUTOFMEMORY;
212  m_psf = pdcm->psf;
213  m_pmcb = pdcm->pcmcb;
214  m_pfnmcb = lpfn;
215 
216  m_cKeys = pdcm->cKeys;
217  if (pdcm->cKeys)
218  {
219  m_aKeys = (HKEY*)HeapAlloc(GetProcessHeap(), 0, sizeof(HKEY) * pdcm->cKeys);
220  if (!m_aKeys)
221  return E_OUTOFMEMORY;
222  memcpy(m_aKeys, pdcm->aKeys, sizeof(HKEY) * pdcm->cKeys);
223  }
224 
225  m_psf->GetUIObjectOf(pdcm->hwnd, m_cidl, m_apidl, IID_NULL_PPV_ARG(IDataObject, &m_pDataObj));
226 
227  if (pdcm->pidlFolder)
228  {
230  }
231  else
232  {
234  if (SUCCEEDED(m_psf->QueryInterface(IID_PPV_ARG(IPersistFolder2, &pf))))
235  {
236  if (FAILED(pf->GetCurFolder(&m_pidlFolder)))
237  ERR("GetCurFolder failed\n");
238  }
239  TRACE("pidlFolder %p\n", m_pidlFolder);
240  }
241 
242  return S_OK;
243 }
const HKEY * aKeys
Definition: shlobj.h:2373
IContextMenuCB * pcmcb
Definition: shlobj.h:2366
PIDLIST_ABSOLUTE m_pidlFolder
#define IID_PPV_ARG(Itype, ppType)
IShellFolder * psf
Definition: shlobj.h:2368
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
#define IID_NULL_PPV_ARG(Itype, ppType)
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:403
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:109
#define S_OK
Definition: intsafe.h:59
CComPtr< IDataObject > m_pDataObj
LPITEMIDLIST WINAPI ILClone(LPCITEMIDLIST pidl)
Definition: pidl.c:228
HANDLE HKEY
Definition: registry.h:24
CComPtr< IContextMenuCB > m_pmcb
PCUITEMID_CHILD_ARRAY apidl
Definition: shlobj.h:2370
PCIDLIST_ABSOLUTE pidlFolder
Definition: shlobj.h:2367
PITEMID_CHILD * _ILCopyaPidl(PCUITEMID_CHILD_ARRAY apidlsrc, UINT cidl)
Definition: pidl.c:2638
#define SUCCEEDED(hr)
Definition: intsafe.h:57
PCUITEMID_CHILD_ARRAY m_apidl

◆ InvokeCommand()

HRESULT WINAPI CDefaultContextMenu::InvokeCommand ( LPCMINVOKECOMMANDINFO  lpcmi)
virtual

Implements IContextMenu.

Definition at line 1179 of file CDefaultContextMenu.cpp.

1181 {
1182  CMINVOKECOMMANDINFO LocalInvokeInfo;
1183  HRESULT Result;
1184  UINT CmdId;
1185 
1186  /* Take a local copy of the fixed members of the
1187  struct as we might need to modify the verb */
1188  LocalInvokeInfo = *lpcmi;
1189 
1190  /* Check if this is a string verb */
1191  if (HIWORD(LocalInvokeInfo.lpVerb))
1192  {
1193  /* Get the ID which corresponds to this verb, and update our local copy */
1194  if (MapVerbToCmdId((LPVOID)LocalInvokeInfo.lpVerb, &CmdId, FALSE))
1195  LocalInvokeInfo.lpVerb = MAKEINTRESOURCEA(CmdId);
1196  }
1197 
1198  CmdId = LOWORD(LocalInvokeInfo.lpVerb);
1199 
1200  if (m_pDynamicEntries && CmdId >= m_iIdSHEFirst && CmdId < m_iIdSHELast)
1201  {
1202  LocalInvokeInfo.lpVerb -= m_iIdSHEFirst;
1203  Result = InvokeShellExt(&LocalInvokeInfo);
1204  return Result;
1205  }
1206 
1207  if (m_pStaticEntries && CmdId >= m_iIdSCMFirst && CmdId < m_iIdSCMLast)
1208  {
1209  LocalInvokeInfo.lpVerb -= m_iIdSCMFirst;
1210  Result = InvokeRegVerb(&LocalInvokeInfo);
1211  return Result;
1212  }
1213 
1214  if (m_iIdCBFirst != m_iIdCBLast && CmdId >= m_iIdCBFirst && CmdId < m_iIdCBLast)
1215  {
1217  return Result;
1218  }
1219 
1220  if (m_iIdDfltFirst != m_iIdDfltLast && CmdId >= m_iIdDfltFirst && CmdId < m_iIdDfltLast)
1221  {
1222  CmdId -= m_iIdDfltFirst;
1223  /* See the definitions of IDM_CUT and co to see how this works */
1224  CmdId += 0x7000;
1225  }
1226 
1227  /* Check if this is a Id */
1228  switch (CmdId)
1229  {
1230  case FCIDM_SHVIEW_INSERT:
1231  Result = DoPaste(&LocalInvokeInfo, FALSE);
1232  break;
1234  Result = DoPaste(&LocalInvokeInfo, TRUE);
1235  break;
1236  case FCIDM_SHVIEW_OPEN:
1237  case FCIDM_SHVIEW_EXPLORE:
1238  Result = DoOpenOrExplore(&LocalInvokeInfo);
1239  break;
1240  case FCIDM_SHVIEW_COPY:
1241  case FCIDM_SHVIEW_CUT:
1242  Result = DoCopyOrCut(&LocalInvokeInfo, CmdId == FCIDM_SHVIEW_COPY);
1243  break;
1245  Result = DoCreateLink(&LocalInvokeInfo);
1246  break;
1247  case FCIDM_SHVIEW_DELETE:
1248  Result = DoDelete(&LocalInvokeInfo);
1249  break;
1250  case FCIDM_SHVIEW_RENAME:
1251  Result = DoRename(&LocalInvokeInfo);
1252  break;
1254  Result = DoProperties(&LocalInvokeInfo);
1255  break;
1257  Result = DoCreateNewFolder(&LocalInvokeInfo);
1258  break;
1259  default:
1260  Result = E_INVALIDARG;
1261  ERR("Unhandled Verb %xl\n", LOWORD(LocalInvokeInfo.lpVerb));
1262  break;
1263  }
1264 
1265  return Result;
1266 }
#define TRUE
Definition: types.h:120
struct IContextMenu::tagCMINVOKECOMMANDINFO CMINVOKECOMMANDINFO
HRESULT DoPaste(LPCMINVOKECOMMANDINFO lpcmi, BOOL bLink)
#define FCIDM_SHVIEW_OPEN
Definition: shresdef.h:777
#define MAKEINTRESOURCEA(i)
Definition: winuser.h:581
HRESULT DoRename(LPCMINVOKECOMMANDINFO lpcmi)
HRESULT InvokeRegVerb(LPCMINVOKECOMMANDINFO lpcmi)
#define FCIDM_SHVIEW_PROPERTIES
Definition: shresdef.h:750
#define FCIDM_SHVIEW_INSERTLINK
Definition: shresdef.h:755
HRESULT DoOpenOrExplore(LPCMINVOKECOMMANDINFO lpcmi)
#define FCIDM_SHVIEW_INSERT
Definition: shresdef.h:753
#define E_INVALIDARG
Definition: ddrawi.h:101
#define DFM_INVOKECOMMAND
Definition: precomp.h:45
smooth NULL
Definition: ftsmooth.c:416
_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:773
HRESULT InvokeShellExt(LPCMINVOKECOMMANDINFO lpcmi)
#define FCIDM_SHVIEW_EXPLORE
Definition: shresdef.h:776
#define FCIDM_SHVIEW_COPY
Definition: shresdef.h:752
LONG HRESULT
Definition: typedefs.h:78
HRESULT DoProperties(LPCMINVOKECOMMANDINFO lpcmi)
#define FCIDM_SHVIEW_DELETE
Definition: shresdef.h:749
HRESULT DoCopyOrCut(LPCMINVOKECOMMANDINFO lpcmi, BOOL bCopy)
HRESULT DoCreateLink(LPCMINVOKECOMMANDINFO lpcmi)
#define FCIDM_SHVIEW_CREATELINK
Definition: shresdef.h:771
HRESULT DoCreateNewFolder(LPCMINVOKECOMMANDINFO lpici)
#define ERR(fmt,...)
Definition: debug.h:109
#define FCIDM_SHVIEW_RENAME
Definition: shresdef.h:770
PDynamicShellEntry m_pDynamicEntries
unsigned int UINT
Definition: ndis.h:50
HRESULT _DoCallback(UINT uMsg, WPARAM wParam, LPVOID lParam)
#define HIWORD(l)
Definition: typedefs.h:247
#define FCIDM_SHVIEW_CUT
Definition: shresdef.h:751
HRESULT DoDelete(LPCMINVOKECOMMANDINFO lpcmi)
PStaticShellEntry m_pStaticEntries
BOOL MapVerbToCmdId(PVOID Verb, PUINT idCmd, BOOL IsUnicode)
#define LOWORD(l)
Definition: pedump.c:82

◆ InvokePidl()

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

Definition at line 1089 of file CDefaultContextMenu.cpp.

1090 {
1091  LPITEMIDLIST pidlFull = ILCombine(m_pidlFolder, pidl);
1092  if (pidlFull == NULL)
1093  {
1094  return E_FAIL;
1095  }
1096 
1097  WCHAR wszPath[MAX_PATH];
1098  BOOL bHasPath = SHGetPathFromIDListW(pidlFull, wszPath);
1099 
1100  WCHAR wszDir[MAX_PATH];
1101  if (bHasPath)
1102  {
1103  wcscpy(wszDir, wszPath);
1104  PathRemoveFileSpec(wszDir);
1105  }
1106  else
1107  {
1109  }
1110 
1111  SHELLEXECUTEINFOW sei;
1112  ZeroMemory(&sei, sizeof(sei));
1113  sei.cbSize = sizeof(sei);
1114  sei.hwnd = lpcmi->hwnd;
1115  sei.nShow = SW_SHOWNORMAL;
1116  sei.lpVerb = pEntry->szVerb;
1117  sei.lpDirectory = wszDir;
1118  sei.lpIDList = pidlFull;
1119  sei.hkeyClass = pEntry->hkClass;
1121  if (bHasPath)
1122  {
1123  sei.lpFile = wszPath;
1124  }
1125 
1126  ShellExecuteExW(&sei);
1127 
1128  ILFree(pidlFull);
1129 
1130  return S_OK;
1131 }
#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:1280
PIDLIST_ABSOLUTE m_pidlFolder
#define ZeroMemory
Definition: winbase.h:1642
#define E_FAIL
Definition: ddrawi.h:102
unsigned int BOOL
Definition: ntddk_ex.h:94
LPCWSTR lpDirectory
Definition: shellapi.h:332
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI DECLSPEC_HOTPATCH ShellExecuteExW(LPSHELLEXECUTEINFOW sei)
Definition: shlexec.cpp:2255
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
_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:59
#define SW_SHOWNORMAL
Definition: winuser.h:764
#define SEE_MASK_IDLIST
Definition: shellapi.h:27
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41

Referenced by InvokeRegVerb().

◆ InvokeRegVerb()

HRESULT CDefaultContextMenu::InvokeRegVerb ( LPCMINVOKECOMMANDINFO  lpcmi)
private

Definition at line 1134 of file CDefaultContextMenu.cpp.

1136 {
1138  INT iCmd = LOWORD(lpcmi->lpVerb) - m_iIdSCMFirst;
1139  HRESULT hr;
1140  UINT i;
1141 
1142  while (pEntry && (iCmd--) > 0)
1143  pEntry = pEntry->pNext;
1144 
1145  if (iCmd > 0)
1146  return E_FAIL;
1147 
1148  /* Get the browse flags to see if we need to browse */
1149  DWORD wFlags = BrowserFlagsFromVerb(lpcmi, pEntry);
1150  BOOL bBrowsed = FALSE;
1151 
1152  for (i=0; i < m_cidl; i++)
1153  {
1154  /* Check if we need to browse */
1155  if (wFlags > 0)
1156  {
1157  /* In xp if we have browsed, we don't open any more folders.
1158  * In win7 we browse to the first folder we find and
1159  * open new windows for each of the rest of the folders */
1160  if (bBrowsed)
1161  continue;
1162 
1163  hr = TryToBrowse(lpcmi, m_apidl[i], wFlags);
1164  if (SUCCEEDED(hr))
1165  {
1166  bBrowsed = TRUE;
1167  continue;
1168  }
1169  }
1170 
1171  InvokePidl(lpcmi, m_apidl[i], pEntry);
1172  }
1173 
1174  return S_OK;
1175 }
#define TRUE
Definition: types.h:120
HRESULT hr
Definition: shlfolder.c:183
#define E_FAIL
Definition: ddrawi.h:102
int32_t INT
Definition: typedefs.h:57
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 BOOL
Definition: ntddk_ex.h:94
HRESULT TryToBrowse(LPCMINVOKECOMMANDINFO lpcmi, LPCITEMIDLIST pidl, DWORD wFlags)
LONG HRESULT
Definition: typedefs.h:78
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_ DWORD _Out_ _In_ WORD wFlags
Definition: wincon.h:534
DWORD BrowserFlagsFromVerb(LPCMINVOKECOMMANDINFO lpcmi, PStaticShellEntry pEntry)
#define S_OK
Definition: intsafe.h:59
struct _StaticShellEntry_ * pNext
unsigned int UINT
Definition: ndis.h:50
HRESULT InvokePidl(LPCMINVOKECOMMANDINFO lpcmi, LPCITEMIDLIST pidl, PStaticShellEntry pEntry)
PStaticShellEntry m_pStaticEntries
#define LOWORD(l)
Definition: pedump.c:82
#define SUCCEEDED(hr)
Definition: intsafe.h:57
PCUITEMID_CHILD_ARRAY m_apidl

Referenced by InvokeCommand().

◆ InvokeShellExt()

HRESULT CDefaultContextMenu::InvokeShellExt ( LPCMINVOKECOMMANDINFO  lpcmi)
private

Definition at line 1016 of file CDefaultContextMenu.cpp.

1018 {
1019  TRACE("verb %p first %x last %x\n", lpcmi->lpVerb, m_iIdSHEFirst, m_iIdSHELast);
1020 
1021  UINT idCmd = LOWORD(lpcmi->lpVerb);
1022  PDynamicShellEntry pEntry = GetDynamicEntry(idCmd);
1023  if (!pEntry)
1024  return E_FAIL;
1025 
1026  /* invoke the dynamic context menu */
1027  lpcmi->lpVerb = MAKEINTRESOURCEA(idCmd - pEntry->iIdCmdFirst);
1028  return pEntry->pCM->InvokeCommand(lpcmi);
1029 }
#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
HRESULT InvokeCommand([in] LPCMINVOKECOMMANDINFO lpici)
#define LOWORD(l)
Definition: pedump.c:82

Referenced by InvokeCommand().

◆ IsShellExtensionAlreadyLoaded()

BOOL CDefaultContextMenu::IsShellExtensionAlreadyLoaded ( const CLSID pclsid)
private

Definition at line 341 of file CDefaultContextMenu.cpp.

342 {
344 
345  while (pEntry)
346  {
347  if (!memcmp(&pEntry->ClassID, pclsid, sizeof(CLSID)))
348  return TRUE;
349  pEntry = pEntry->pNext;
350  }
351 
352  return FALSE;
353 }
#define TRUE
Definition: types.h:120
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
struct _DynamicShellEntry_ * pNext
PDynamicShellEntry m_pDynamicEntries

Referenced by LoadDynamicContextMenuHandler().

◆ LoadDynamicContextMenuHandler()

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

Definition at line 356 of file CDefaultContextMenu.cpp.

357 {
358  HRESULT hr;
359 
360  TRACE("LoadDynamicContextMenuHandler entered with This %p hKey %p pclsid %s\n", this, hKey, wine_dbgstr_guid(pclsid));
361 
362  if (IsShellExtensionAlreadyLoaded(pclsid))
363  return S_OK;
364 
367  if (FAILED(hr))
368  {
369  ERR("SHCoCreateInstance(IContextMenu) failed.clsid %s hr 0x%x\n", wine_dbgstr_guid(pclsid), hr);
370  return hr;
371  }
372 
373  CComPtr<IShellExtInit> pExtInit;
374  hr = pcm->QueryInterface(IID_PPV_ARG(IShellExtInit, &pExtInit));
375  if (FAILED(hr))
376  {
377  ERR("IContextMenu->QueryInterface(IShellExtInit) failed.clsid %s hr 0x%x\n", wine_dbgstr_guid(pclsid), hr);
378  return hr;
379  }
380 
381  hr = pExtInit->Initialize(m_pidlFolder, m_pDataObj, hKey);
382  if (FAILED(hr))
383  {
384  WARN("IShellExtInit::Initialize failed.clsid %s hr 0x%x\n", wine_dbgstr_guid(pclsid), hr);
385  return hr;
386  }
387 
388  if (m_site)
389  IUnknown_SetSite(pcm, m_site);
390 
392  if (!pEntry)
393  return E_OUTOFMEMORY;
394 
395  pEntry->iIdCmdFirst = 0;
396  pEntry->pNext = NULL;
397  pEntry->NumIds = 0;
398  pEntry->pCM = pcm.Detach();
399  memcpy(&pEntry->ClassID, pclsid, sizeof(CLSID));
400 
401  if (m_pDynamicEntries)
402  {
404 
405  while (pLastEntry->pNext)
406  pLastEntry = pLastEntry->pNext;
407 
408  pLastEntry->pNext = pEntry;
409  }
410  else
411  m_pDynamicEntries = pEntry;
412 
413  return S_OK;
414 }
HRESULT hr
Definition: shlfolder.c:183
#define WARN(fmt,...)
Definition: debug.h:111
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:1358
smooth NULL
Definition: ftsmooth.c:416
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:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG HRESULT
Definition: typedefs.h:78
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:109
#define S_OK
Definition: intsafe.h:59
CComPtr< IDataObject > m_pDataObj
PDynamicShellEntry m_pDynamicEntries
T * Detach()
Definition: atlcomcli.h:156
struct _DynamicShellEntry_ DynamicShellEntry

Referenced by EnumerateDynamicContextHandlerForKey().

◆ MapVerbToCmdId()

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

Definition at line 983 of file CDefaultContextMenu.cpp.

984 {
985  WCHAR UnicodeStr[MAX_VERB];
986 
987  /* Loop through all the static verbs looking for a match */
988  for (UINT i = 0; i < _countof(g_StaticInvokeCmdMap); i++)
989  {
990  /* We can match both ANSI and unicode strings */
991  if (IsUnicode)
992  {
993  /* The static verbs are ANSI, get a unicode version before doing the compare */
994  SHAnsiToUnicode(g_StaticInvokeCmdMap[i].szStringVerb, UnicodeStr, MAX_VERB);
995  if (!wcscmp(UnicodeStr, (LPWSTR)Verb))
996  {
997  /* Return the Corresponding Id */
998  *idCmd = g_StaticInvokeCmdMap[i].IntVerb;
999  return TRUE;
1000  }
1001  }
1002  else
1003  {
1004  if (!strcmp(g_StaticInvokeCmdMap[i].szStringVerb, (LPSTR)Verb))
1005  {
1006  *idCmd = g_StaticInvokeCmdMap[i].IntVerb;
1007  return TRUE;
1008  }
1009  }
1010  }
1011 
1012  return FALSE;
1013 }
#define TRUE
Definition: types.h:120
struct _StaticInvokeCommandMap_ g_StaticInvokeCmdMap[]
#define _countof(array)
Definition: fontsub.cpp:30
char * LPSTR
Definition: xmlstorage.h:182
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 MAX_VERB
__wchar_t WCHAR
Definition: xmlstorage.h:180
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
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
DWORD WINAPI SHAnsiToUnicode(LPCSTR lpSrcStr, LPWSTR lpDstStr, int iLen)
Definition: string.c:2625

Referenced by InvokeCommand().

◆ QueryContextMenu()

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

Implements IContextMenu.

Definition at line 672 of file CDefaultContextMenu.cpp.

678 {
679  HRESULT hr;
680  UINT idCmdNext = idCmdFirst;
681  UINT cIds = 0;
682 
683  TRACE("BuildShellItemContextMenu entered\n");
684 
685  /* Load static verbs and shell extensions from registry */
686  for (UINT i = 0; i < m_cKeys; i++)
687  {
690  }
691 
692  /* Add static context menu handlers */
693  cIds = AddStaticContextMenusToMenu(hMenu, &IndexMenu, idCmdFirst, idCmdLast);
694  m_iIdSCMFirst = 0;
695  m_iIdSCMLast = cIds;
696  idCmdNext = idCmdFirst + cIds;
697 
698  /* Add dynamic context menu handlers */
699  cIds += AddShellExtensionsToMenu(hMenu, &IndexMenu, idCmdNext, idCmdLast);
701  m_iIdSHELast = cIds;
702  idCmdNext = idCmdFirst + cIds;
703  TRACE("SH_LoadContextMenuHandlers first %x last %x\n", m_iIdSHEFirst, m_iIdSHELast);
704 
705  /* Now let the callback add its own items */
706  QCMINFO qcminfo = {hMenu, IndexMenu, idCmdNext, idCmdLast, NULL};
708  {
709  cIds += qcminfo.idCmdFirst;
710  IndexMenu += qcminfo.idCmdFirst;
712  m_iIdCBLast = cIds;
713  idCmdNext = idCmdFirst + cIds;
714  }
715 
716  if (uFlags & CMF_VERBSONLY)
717  return MAKE_HRESULT(SEVERITY_SUCCESS, 0, cIds);
718 
719  /* If this is a background context menu we are done */
720  if (!m_cidl)
721  return MAKE_HRESULT(SEVERITY_SUCCESS, 0, cIds);
722 
723  /* Get the attributes of the items */
724  SFGAOF rfg = SFGAO_BROWSABLE | SFGAO_CANCOPY | SFGAO_CANLINK | SFGAO_CANMOVE | SFGAO_CANDELETE | SFGAO_CANRENAME | SFGAO_HASPROPSHEET | SFGAO_FILESYSTEM | SFGAO_FOLDER;
725  hr = m_psf->GetAttributesOf(m_cidl, m_apidl, &rfg);
726  if (FAILED_UNEXPECTEDLY(hr))
727  return MAKE_HRESULT(SEVERITY_SUCCESS, 0, cIds);
728 
729  /* Add the default part of the menu */
730  HMENU hmenuDefault = LoadMenu(_AtlBaseModule.GetResourceInstance(), L"MENU_SHV_FILE");
731 
732  /* Remove uneeded entries */
733  if (!(rfg & SFGAO_CANMOVE))
734  DeleteMenu(hmenuDefault, IDM_CUT, MF_BYCOMMAND);
735  if (!(rfg & SFGAO_CANCOPY))
736  DeleteMenu(hmenuDefault, IDM_COPY, MF_BYCOMMAND);
737  if (!((rfg & SFGAO_FILESYSTEM) && HasClipboardData()))
738  DeleteMenu(hmenuDefault, IDM_INSERT, MF_BYCOMMAND);
739  if (!(rfg & SFGAO_CANLINK))
740  DeleteMenu(hmenuDefault, IDM_CREATELINK, MF_BYCOMMAND);
741  if (!(rfg & SFGAO_CANDELETE))
742  DeleteMenu(hmenuDefault, IDM_DELETE, MF_BYCOMMAND);
743  if (!(rfg & SFGAO_CANRENAME))
744  DeleteMenu(hmenuDefault, IDM_RENAME, MF_BYCOMMAND);
745  if (!(rfg & SFGAO_HASPROPSHEET))
746  DeleteMenu(hmenuDefault, IDM_PROPERTIES, MF_BYCOMMAND);
747 
748  UINT idMax = Shell_MergeMenus(hMenu, GetSubMenu(hmenuDefault, 0), IndexMenu, idCmdNext, idCmdLast, 0);
749  m_iIdDfltFirst = cIds;
750  cIds += idMax - idCmdNext;
751  m_iIdDfltLast = cIds;
752 
753  DestroyMenu(hmenuDefault);
754 
755  return MAKE_HRESULT(SEVERITY_SUCCESS, 0, cIds);
756 }
#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:790
UINT uFlags
Definition: api.c:59
#define IDM_COPY
Definition: shresdef.h:786
#define SEVERITY_SUCCESS
Definition: winerror.h:64
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
smooth NULL
Definition: ftsmooth.c:416
#define MAKE_HRESULT(sev, fac, code)
Definition: dmerror.h:30
#define IDM_DELETE
Definition: shresdef.h:789
BOOL EnumerateDynamicContextHandlerForKey(HKEY hRootKey)
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:78
BOOL WINAPI DeleteMenu(_In_ HMENU, _In_ UINT, _In_ UINT)
UINT idCmdFirst
Definition: shlobj.h:1316
#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
unsigned int UINT
Definition: ndis.h:50
#define IDM_CUT
Definition: shresdef.h:785
HRESULT _DoCallback(UINT uMsg, WPARAM wParam, LPVOID lParam)
UINT AddShellExtensionsToMenu(HMENU hMenu, UINT *pIndexMenu, UINT idCmdFirst, UINT idCmdLast)
#define IDM_CREATELINK
Definition: shresdef.h:788
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:787
static BOOL HasClipboardData()
static IShellFolder IShellItem **static IBindCtx LPITEMIDLIST SFGAOF
Definition: ebrowser.c:83
#define SUCCEEDED(hr)
Definition: intsafe.h:57
PCUITEMID_CHILD_ARRAY m_apidl

◆ SetSite()

HRESULT WINAPI CDefaultContextMenu::SetSite ( IUnknown pUnkSite)
virtual

Implements IObjectWithSite.

Definition at line 1449 of file CDefaultContextMenu.cpp.

1450 {
1451  m_site = pUnkSite;
1452  return S_OK;
1453 }
CComPtr< IUnknown > m_site
#define S_OK
Definition: intsafe.h:59

◆ TryToBrowse()

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

Definition at line 1071 of file CDefaultContextMenu.cpp.

1073 {
1075  HRESULT hr;
1076 
1077  if (!m_site)
1078  return E_FAIL;
1079 
1080  /* Get a pointer to the shell browser */
1082  if (FAILED_UNEXPECTEDLY(hr))
1083  return 0;
1084 
1085  return psb->BrowseObject(ILCombine(m_pidlFolder, pidl), wFlags);
1086 }
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:1448
LONG HRESULT
Definition: typedefs.h:78
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
CComPtr< IUnknown > m_site
_In_ DWORD _Out_ _In_ WORD wFlags
Definition: wincon.h:534
#define SID_IShellBrowser

Referenced by InvokeRegVerb().

Member Data Documentation

◆ m_aKeys

HKEY* CDefaultContextMenu::m_aKeys
private

Definition at line 75 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 78 of file CDefaultContextMenu.cpp.

Referenced by EnumerateDynamicContextHandlerForKey().

◆ m_cidl

UINT CDefaultContextMenu::m_cidl
private

◆ m_cKeys

UINT CDefaultContextMenu::m_cKeys
private

Definition at line 76 of file CDefaultContextMenu.cpp.

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

◆ m_iIdCBFirst

UINT CDefaultContextMenu::m_iIdCBFirst
private

Definition at line 85 of file CDefaultContextMenu.cpp.

Referenced by InvokeCommand(), and QueryContextMenu().

◆ m_iIdCBLast

UINT CDefaultContextMenu::m_iIdCBLast
private

Definition at line 86 of file CDefaultContextMenu.cpp.

Referenced by InvokeCommand(), and QueryContextMenu().

◆ m_iIdDfltFirst

UINT CDefaultContextMenu::m_iIdDfltFirst
private

Definition at line 87 of file CDefaultContextMenu.cpp.

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

◆ m_iIdDfltLast

UINT CDefaultContextMenu::m_iIdDfltLast
private

Definition at line 88 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 84 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 71 of file CDefaultContextMenu.cpp.

Referenced by _DoCallback(), and Initialize().

◆ m_pidlFolder

PIDLIST_ABSOLUTE CDefaultContextMenu::m_pidlFolder
private

◆ m_pmcb

CComPtr<IContextMenuCB> CDefaultContextMenu::m_pmcb
private

Definition at line 70 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: