mirror of
https://github.com/reactos/reactos.git
synced 2025-02-23 08:55:19 +00:00
[SHELL32] Watch for common desktop and SHCNE_CREATE for IShellLink::Save (#2515)
- On desktop view, we have to watch both the common desktop and the private desktop. - In Windows, IShellLink::Save (shortcut creation) sends SHCNE_CREATE or SHCNE_UPDATEITEM notification. - Simplify CChangeNotify::ShouldNotify. CORE-10391
This commit is contained in:
parent
0d187f7d56
commit
1c706d7483
3 changed files with 50 additions and 45 deletions
|
@ -1157,11 +1157,36 @@ LRESULT CDefView::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandl
|
||||||
SetShellWindowEx(hwndSB, m_ListView);
|
SetShellWindowEx(hwndSB, m_ListView);
|
||||||
}
|
}
|
||||||
|
|
||||||
SHChangeNotifyEntry ntreg;
|
INT nRegCount;
|
||||||
ntreg.fRecursive = TRUE;
|
SHChangeNotifyEntry ntreg[3];
|
||||||
ntreg.pidl = m_pidlParent;
|
PIDLIST_ABSOLUTE pidls[3];
|
||||||
|
if (_ILIsDesktop(m_pidlParent))
|
||||||
|
{
|
||||||
|
nRegCount = 3;
|
||||||
|
SHGetSpecialFolderLocation(m_hWnd, CSIDL_DESKTOPDIRECTORY, &pidls[0]);
|
||||||
|
SHGetSpecialFolderLocation(m_hWnd, CSIDL_COMMON_DESKTOPDIRECTORY, &pidls[1]);
|
||||||
|
SHGetSpecialFolderLocation(m_hWnd, CSIDL_BITBUCKET, &pidls[2]);
|
||||||
|
ntreg[0].fRecursive = FALSE;
|
||||||
|
ntreg[0].pidl = pidls[0];
|
||||||
|
ntreg[1].fRecursive = FALSE;
|
||||||
|
ntreg[1].pidl = pidls[1];
|
||||||
|
ntreg[2].fRecursive = FALSE;
|
||||||
|
ntreg[2].pidl = pidls[2];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nRegCount = 1;
|
||||||
|
ntreg[0].fRecursive = FALSE;
|
||||||
|
ntreg[0].pidl = m_pidlParent;
|
||||||
|
}
|
||||||
m_hNotify = SHChangeNotifyRegister(m_hWnd, SHCNRF_NewDelivery | SHCNRF_ShellLevel,
|
m_hNotify = SHChangeNotifyRegister(m_hWnd, SHCNRF_NewDelivery | SHCNRF_ShellLevel,
|
||||||
SHCNE_ALLEVENTS, SHV_CHANGE_NOTIFY, 1, &ntreg);
|
SHCNE_ALLEVENTS, SHV_CHANGE_NOTIFY, nRegCount, ntreg);
|
||||||
|
if (nRegCount == 3)
|
||||||
|
{
|
||||||
|
ILFree(pidls[0]);
|
||||||
|
ILFree(pidls[1]);
|
||||||
|
ILFree(pidls[2]);
|
||||||
|
}
|
||||||
|
|
||||||
/* _DoFolderViewCB(SFVM_GETNOTIFY, ?? ??) */
|
/* _DoFolderViewCB(SFVM_GETNOTIFY, ?? ??) */
|
||||||
|
|
||||||
|
|
|
@ -344,11 +344,16 @@ HRESULT STDMETHODCALLTYPE CShellLink::Load(LPCOLESTR pszFileName, DWORD dwMode)
|
||||||
|
|
||||||
HRESULT STDMETHODCALLTYPE CShellLink::Save(LPCOLESTR pszFileName, BOOL fRemember)
|
HRESULT STDMETHODCALLTYPE CShellLink::Save(LPCOLESTR pszFileName, BOOL fRemember)
|
||||||
{
|
{
|
||||||
|
BOOL bAlreadyExists;
|
||||||
|
WCHAR szFullPath[MAX_PATH];
|
||||||
|
|
||||||
TRACE("(%p)->(%s)\n", this, debugstr_w(pszFileName));
|
TRACE("(%p)->(%s)\n", this, debugstr_w(pszFileName));
|
||||||
|
|
||||||
if (!pszFileName)
|
if (!pszFileName)
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
|
|
||||||
|
bAlreadyExists = PathFileExistsW(pszFileName);
|
||||||
|
|
||||||
CComPtr<IStream> stm;
|
CComPtr<IStream> stm;
|
||||||
HRESULT hr = SHCreateStreamOnFileW(pszFileName, STGM_READWRITE | STGM_CREATE | STGM_SHARE_EXCLUSIVE, &stm);
|
HRESULT hr = SHCreateStreamOnFileW(pszFileName, STGM_READWRITE | STGM_CREATE | STGM_SHARE_EXCLUSIVE, &stm);
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
|
@ -357,6 +362,12 @@ HRESULT STDMETHODCALLTYPE CShellLink::Save(LPCOLESTR pszFileName, BOOL fRemember
|
||||||
|
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
{
|
{
|
||||||
|
GetFullPathNameW(pszFileName, _countof(szFullPath), szFullPath, NULL);
|
||||||
|
if (bAlreadyExists)
|
||||||
|
SHChangeNotify(SHCNE_UPDATEITEM, SHCNF_PATHW, szFullPath, NULL);
|
||||||
|
else
|
||||||
|
SHChangeNotify(SHCNE_CREATE, SHCNF_PATHW, szFullPath, NULL);
|
||||||
|
|
||||||
if (m_sLinkPath)
|
if (m_sLinkPath)
|
||||||
HeapFree(GetProcessHeap(), 0, m_sLinkPath);
|
HeapFree(GetProcessHeap(), 0, m_sLinkPath);
|
||||||
|
|
||||||
|
|
|
@ -536,58 +536,27 @@ BOOL CChangeNotify::DoDelivery(HANDLE hTicket, DWORD dwOwnerPID)
|
||||||
|
|
||||||
BOOL CChangeNotify::ShouldNotify(LPDELITICKET pTicket, LPNOTIFSHARE pShared)
|
BOOL CChangeNotify::ShouldNotify(LPDELITICKET pTicket, LPNOTIFSHARE pShared)
|
||||||
{
|
{
|
||||||
BOOL ret = FALSE;
|
BOOL ret;
|
||||||
LPITEMIDLIST pidl = NULL, pidl1 = NULL, pidl2 = NULL;
|
LPITEMIDLIST pidl, pidl1, pidl2;
|
||||||
WCHAR szPath[MAX_PATH], szPath1[MAX_PATH], szPath2[MAX_PATH];
|
|
||||||
INT cch, cch1, cch2;
|
|
||||||
|
|
||||||
szPath[0] = szPath1[0] = szPath2[0] = 0;
|
if (!pShared->ibPidl)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
if (pShared->ibPidl)
|
ret = FALSE;
|
||||||
{
|
|
||||||
pidl = (LPITEMIDLIST)((LPBYTE)pShared + pShared->ibPidl);
|
pidl = (LPITEMIDLIST)((LPBYTE)pShared + pShared->ibPidl);
|
||||||
SHGetPathFromIDListW(pidl, szPath);
|
|
||||||
PathAddBackslashW(szPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pTicket->ibOffset1)
|
if (!ret && pTicket->ibOffset1)
|
||||||
{
|
{
|
||||||
pidl1 = (LPITEMIDLIST)((LPBYTE)pTicket + pTicket->ibOffset1);
|
pidl1 = (LPITEMIDLIST)((LPBYTE)pTicket + pTicket->ibOffset1);
|
||||||
if (ILIsEqual(pidl, pidl1))
|
if (ILIsEqual(pidl, pidl1) || ILIsParent(pidl, pidl1, !pShared->fRecursive))
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
SHGetPathFromIDListW(pidl1, szPath1);
|
|
||||||
PathAddBackslashW(szPath1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pTicket->ibOffset2)
|
if (!ret && pTicket->ibOffset2)
|
||||||
{
|
{
|
||||||
pidl2 = (LPITEMIDLIST)((LPBYTE)pTicket + pTicket->ibOffset2);
|
pidl2 = (LPITEMIDLIST)((LPBYTE)pTicket + pTicket->ibOffset2);
|
||||||
if (ILIsEqual(pidl, pidl2))
|
if (ILIsEqual(pidl, pidl2) || ILIsParent(pidl, pidl2, !pShared->fRecursive))
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
SHGetPathFromIDListW(pidl2, szPath2);
|
|
||||||
PathAddBackslashW(szPath2);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pShared->fRecursive)
|
|
||||||
{
|
|
||||||
if (szPath1[0] == 0)
|
|
||||||
ret = TRUE;
|
|
||||||
|
|
||||||
cch = lstrlenW(szPath);
|
|
||||||
cch1 = lstrlenW(szPath1);
|
|
||||||
cch2 = lstrlenW(szPath2);
|
|
||||||
if (cch < cch1)
|
|
||||||
{
|
|
||||||
szPath1[cch] = 0;
|
|
||||||
if (lstrcmpiW(szPath, szPath1) == 0)
|
|
||||||
ret = TRUE;
|
|
||||||
}
|
|
||||||
if (cch < cch2)
|
|
||||||
{
|
|
||||||
szPath2[cch] = 0;
|
|
||||||
if (lstrcmpiW(szPath, szPath2) == 0)
|
|
||||||
ret = TRUE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Loading…
Reference in a new issue