SHChangeNotifyRegister()注册了一个消息监控文件夹被删除的消息
我在一个对话框中做了一下工作,我在SHChangeNotifyRegister()注册了一个消息函数
OnMediaChanged()
HWND hWnd = GetSafeHwnd();
LPITEMIDLIST ppidl;
if(SHGetSpecialFolderLocation(hWnd, CSIDL_DESKTOP, &ppidl) == NOERROR)
{
SHChangeNotifyEntry shCNE = {0};
shCNE.pidl = ppidl;
shCNE.fRecursive = TRUE;
m_ulSHChangeNotifyRegister = SHChangeNotifyRegister
(hWnd,
SHCNRF_InterruptLevel |SHCNRF_ShellLevel
SHCNE_RMDIR ,
WM_USER_MEDIACHANGED,
1,
&shCNE);
ASSERT(m_ulSHChangeNotifyRegister != 0);
}
else
ASSERT(FALSE);
下面是消息函数OnMediaChanged()的实现部分
LRESULT CCsDlg::OnMediaChanged(WPARAM wParam, LPARAM lParam)
{
SHNOTIFYSTRUCT *shns = (SHNOTIFYSTRUCT *)wParam;
CString strPath;
CString strMsg;
switch(lParam)
{
case SHCNE_DELETE://文件被删除
{
strPath = GetPathFromPIDL(shns->dwItem1);
if (!strPath.IsEmpty())
{
if (strPath != strMsg)
{
strMsg = strPath;
AfxMessageBox(strPath);
}
}
}
break;
}
监控不到同时删除多于4个的文件夹消息,一个被删除文件夹的路径也得不到
请高手指点 急急急 ?????????