Asked By arloan
15-Dec-09 09:28 AM

Hi all,
I created a very simple shell extension using vc6, implemented IShellExtInit
& IContextMenu interfaces to provide a 'hello' context menu item for
directory background, which shows up a message box with 'hello world!'. It
works perfectly, but I found that it disabled the 'Create New Folder' button
on the toolbar of the shell open/save dialog box. In fact, when I hit the
'Create New Folder' button, the shell calls my extension's
IContextMenu::InvokeCommand() method. Am I doing anything wrong? Thanks for
anybody's help.
The whole project can be download at here:
http://cid-0475c87002affa39.skydrive.live.com/self.aspx/temp/testext.zip
Below is the most significant codes:
// IContextMenu
STDMETHODIMP Cshmenu::QueryContextMenu(HMENU hmenu, UINT indexMenu, UINT
idCmdFirst, UINT idCmdLast, UINT uFlags)
{
if (uFlags & CMF_DEFAULTONLY)
{
return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(0));
}
InsertMenu(hmenu, indexMenu++, MF_BYPOSITION | MF_STRING, idCmdFirst,
_T("&Hello, world!"));
return MAKE_HRESULT(SEVERITY_SUCCESS, 0, 1);
}
STDMETHODIMP Cshmenu::GetCommandString(UINT_PTR idCmd, UINT uFlags, UINT *
pwReserved, LPSTR pszName, UINT cchMax)
{
switch (uFlags)
{
case GCS_HELPTEXTW:
lstrcpyW((LPWSTR)pszName, L"HelloW!");
break;
case GCS_HELPTEXTA:
lstrcpyA(pszName, "HelloA!");
break;
case GCS_VERBW:
lstrcpyW((LPWSTR)pszName, L"test_hello");
break;
case GCS_VERBA:
lstrcpyA(pszName, "test_hello");
break;
}
return S_OK;
}
STDMETHODIMP Cshmenu::InvokeCommand(LPCMINVOKECOMMANDINFO pici)
{
LPCMINVOKECOMMANDINFOEX exinfo = (LPCMINVOKECOMMANDINFOEX)pici;
if (HIWORD(exinfo->lpVerbW))
{
MessageBox(pici->hwnd, _T("Hello, world!"), _T("helloW"),
MB_ICONINFORMATION);
}
else
{
MessageBox(pici->hwnd, _T("Hello, world!"), _T("helloA"),
MB_ICONINFORMATION);
}
return S_OK;
}