|
|
|
date: Sun, 9 Mar 2008 12:51:01 -0700,
group: microsoft.public.platformsdk.shell
back
Shell notifications do not work correctly in custom NSE
Hi
I've encountered an issue with my NSE. When I create or delete or rename
folders in my NSE it often ignores shell notifications about the action
performed so the folder tree or the list folder view do not react to the
changes. The behaviour is unpredictable. Sometimes it works fine when I make
changes in NSE's root folder and doesn't work correctly when I make changes
inside any child folder or vice versa. Actually this it works fine in Vista
and bad in XP. MSDN contains a few of information about NSEs development so I
admit that I could made some mistakes in my code. Let me show you some parts
of it that are responsible for the interacting with shell on my mind.
HRESULT STDMETHODCALLTYPE SV_ShellFolder::CreateViewObject(
/* [in] */ HWND hwnd,
/* [in] */ REFIID riid,
/* [iid_is][out] */ void **ppv)
{
.....
if(riid == __uuidof(IShellView))
{
SFV_CREATE sfv;
sfv.cbSize = sizeof(sfv);
sfv.psvOuter = NULL;
// first of all I'm not sure about QueryInterface. Probably
sfv.pshf = this is enough...
// MSDN does not tell anything about it.
tools::hr_verif(QueryInterface(&sfv.pshf));
// I read that callback handler should be implemented in
separate object but
// I'd tried and that was useless so I decided to implement
IShellFolderViewCB
// in one class with my shell folder. I hope I's right.
tools::hr_verif(QueryInterface(&sfv.psfvcb));
IShellViewPtr view;
tools::hr_verif(SHCreateShellFolderView(&sfv, &view));
this->shell_view = view;
*ppv = view.Detach();
return S_OK;
}
.....
}
HRESULT STDMETHODCALLTYPE SV_ShellFolder::MessageSFVCB(UINT uMsg,
WPARAM wParam,
LPARAM lParam)
{
COM_TRY
{
switch(uMsg)
{
case SFVM_GETNOTIFY:
_DBS("SFVM_GETNOTIFY");
*reinterpret_cast<LPITEMIDLIST*>(wParam) = its_pidl.ptr();
*reinterpret_cast<PLONG>(lParam) = SHCNE_ALLEVENTS;
return S_OK;
case SFVM_FSNOTIFY:
_DBS("SFVM_FSNOTIFY: 0x" <<std::hex <<lParam);
return E_NOTIMPL;
//// Also I'm not sure I need implement SFVM_QUERYFSNOTIFY handler
because MSDN claims that
//// this notification is supported on WinXP SP 2 and higher.
Nevertheless in WinXP SP 1
//// I'd received it !!!
//case SFVM_QUERYFSNOTIFY:
// {
// _DBS("SFVM_QUERYFSNOTIFY");
// SHChangeNotifyEntry* lp = (SHChangeNotifyEntry*)lParam;
// lp->pidl = its_pidl.clone().release();
// lp->fRecursive = TRUE;
// }
// return S_OK;
}
}
COM_CATCH_VOID;
return E_NOTIMPL;
}
After the folder is created I notify the shell about it:
SHChangeNotify(type == SVO_Storage ? SHCNE_MKDIR : SHCNE_CREATE,
SHCNF_IDLIST | SHCNF_FLUSH, pidl1.clone().ptr(), NULL);
But SFVM_FSNOTIFY arrives only if I create a folder inside the root folder
of my NSE. In any other subfolder I don't receive SFVM_FSNOTIFY. I can't work
out what is the reason? Anyway the folder tree and the folder view in
Explorer often do not react on that notification. The same issue is with
deleting and renaming folders.
I'm sure all the pidl's in the code above are correct and any exception does
not occur.
I'll be very thankful for any kind of help. Actually I didn't find ANY
example in the Internet where folder creation, deletion and renaming were
implemented and I'll be glad if somebody shows me one. Also if it is
necessary to show any other part of code I'll show it, just tell me.
Thanks a lot.
date: Sun, 9 Mar 2008 12:51:01 -0700
author: Alexander
|
|