[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:
Katayama Hirofumi MZ
2020-04-09 16:56:54 +09:00
committed by GitHub
parent 0d187f7d56
commit 1c706d7483
3 changed files with 50 additions and 45 deletions

View File

@@ -344,11 +344,16 @@ HRESULT STDMETHODCALLTYPE CShellLink::Load(LPCOLESTR pszFileName, DWORD dwMode)
HRESULT STDMETHODCALLTYPE CShellLink::Save(LPCOLESTR pszFileName, BOOL fRemember)
{
BOOL bAlreadyExists;
WCHAR szFullPath[MAX_PATH];
TRACE("(%p)->(%s)\n", this, debugstr_w(pszFileName));
if (!pszFileName)
return E_FAIL;
bAlreadyExists = PathFileExistsW(pszFileName);
CComPtr<IStream> stm;
HRESULT hr = SHCreateStreamOnFileW(pszFileName, STGM_READWRITE | STGM_CREATE | STGM_SHARE_EXCLUSIVE, &stm);
if (SUCCEEDED(hr))
@@ -357,6 +362,12 @@ HRESULT STDMETHODCALLTYPE CShellLink::Save(LPCOLESTR pszFileName, BOOL fRemember
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)
HeapFree(GetProcessHeap(), 0, m_sLinkPath);