Index: dll/win32/shell32/shelllink.cpp =================================================================== --- dll/win32/shell32/shelllink.cpp (revision 58848) +++ dll/win32/shell32/shelllink.cpp (working copy) @@ -936,12 +936,20 @@ pszFile[0] = 0; if (sPath) + { WideCharToMultiByte(CP_ACP, 0, sPath, -1, - pszFile, cchMaxPath, NULL, NULL); + pszFile, cchMaxPath, NULL, NULL); - if (pfd) FIXME("(%p): WIN32_FIND_DATA is not yet filled.\n", this); + if (pfd) + { + CHAR szPath[MAX_PATH]; + WideCharToMultiByte(CP_ACP, 0, sPath, -1, + szPath, MAX_PATH, NULL, NULL); + FindClose(FindFirstFileA(szPath, pfd)); + } + } - return S_OK; + return (sPath && sPath[0]) ? S_OK : S_FALSE; } HRESULT WINAPI CShellLink::GetIDList(LPITEMIDLIST * ppidl) @@ -949,26 +957,41 @@ TRACE("(%p)->(ppidl=%p)\n", this, ppidl); if (!pPidl) - { *ppidl = NULL; - return S_FALSE; - } + else + *ppidl = ILClone(pPidl); - *ppidl = ILClone(pPidl); return S_OK; } HRESULT WINAPI CShellLink::SetIDList(LPCITEMIDLIST pidl) { + LPWSTR pszPath; + LPITEMIDLIST pidlNew; + TRACE("(%p)->(pidl=%p)\n", this, pidl); + + pidlNew = ILClone(pidl); + if (!pidlNew) + return E_FAIL; + if (pPidl) ILFree(pPidl); + pPidl = pidlNew; - pPidl = ILClone(pidl); - if (!pPidl) + pszPath = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, MAX_PATH * sizeof(WCHAR)); + if (!pszPath) return E_FAIL; + if (SHGetPathFromIDListW(pidl, pszPath)) + { + HeapFree(GetProcessHeap(), 0, sPath); + sPath = pszPath; + } + else + HeapFree(GetProcessHeap(), 0, pszPath); + bDirty = TRUE; return S_OK; @@ -1158,11 +1181,9 @@ /* if we couldn't find an icon yet, look for it using the file system path */ if (FAILED(hr) && sPath) { - LPITEMIDLIST pidl; + LPITEMIDLIST pidl = ILCreateFromPathW(sPath); - hr = pdsk->ParseDisplayName(0, NULL, sPath, NULL, &pidl, NULL); - - if (SUCCEEDED(hr)) + if (pidl) { hr = SHELL_PidlGeticonLocationA(pdsk, pidl, pszIconPath, cchIconPath, piIcon); @@ -1288,9 +1309,10 @@ if (sPath) lstrcpynW(pszFile, sPath, cchMaxPath); - if (pfd) FIXME("(%p): WIN32_FIND_DATA is not yet filled.\n", this); + if (pfd && sPath) + FindClose(FindFirstFileW(sPath, pfd)); - return S_OK; + return (sPath && sPath[0]) ? S_OK : S_FALSE; } HRESULT WINAPI CShellLink::GetDescription(LPWSTR pszName, INT cchMaxName) @@ -1428,11 +1450,8 @@ /* if we couldn't find an icon yet, look for it using the file system path */ if (FAILED(hr) && sPath) { - LPITEMIDLIST pidl; - - hr = pdsk->ParseDisplayName(0, NULL, sPath, NULL, &pidl, NULL); - - if (SUCCEEDED(hr)) + LPITEMIDLIST pidl = ILCreateFromPathW(sPath); + if (pidl) { hr = SHELL_PidlGeticonLocationW(pdsk, pidl, pszIconPath, cchIconPath, piIcon); @@ -1570,6 +1589,7 @@ { LPWSTR unquoted = NULL; HRESULT hr = S_OK; + LPITEMIDLIST pidl = NULL; TRACE("(%p)->(path=%s)\n", this, debugstr_w(pszFile)); @@ -1592,16 +1612,9 @@ return S_FALSE; } - HeapFree(GetProcessHeap(), 0, sPath); - sPath = NULL; - HeapFree(GetProcessHeap(), 0, sComponent); sComponent = NULL; - if (pPidl) - ILFree(pPidl); - pPidl = NULL; - if (S_OK != ShellLink_SetAdvertiseInfo(pszFile)) { WCHAR buffer[MAX_PATH]; @@ -1611,21 +1624,34 @@ *buffer = '\0'; else if (!GetFullPathNameW(pszFile, MAX_PATH, buffer, &fname)) return E_FAIL; - else if(!PathFileExistsW(buffer) && - !SearchPathW(NULL, pszFile, NULL, MAX_PATH, buffer, NULL)) + else if (!PathFileExistsW(buffer) && + !SearchPathW(NULL, pszFile, L".exe", MAX_PATH, buffer, NULL) && + !SearchPathW(NULL, pszFile, L".com", MAX_PATH, buffer, NULL) && + !SearchPathW(NULL, pszFile, L".bat", MAX_PATH, buffer, NULL)) hr = S_FALSE; - pPidl = SHSimpleIDListFromPathW(pszFile); + pidl = SHSimpleIDListFromPathW(buffer); ShellLink_GetVolumeInfo(buffer, &volume); - sPath = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, - (wcslen(buffer) + 1) * sizeof (WCHAR)); - if (!sPath) - return E_OUTOFMEMORY; + if (SUCCEEDED(hr)) + { + HeapFree(GetProcessHeap(), 0, sPath); + sPath = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, + (wcslen(buffer) + 1) * sizeof (WCHAR)); + if (!sPath) + return E_OUTOFMEMORY; - wcscpy(sPath, buffer); + wcscpy(sPath, buffer); + } } + if (SUCCEEDED(hr)) + { + if (pPidl) + ILFree(pPidl); + pPidl = pidl; + } + bDirty = TRUE; HeapFree(GetProcessHeap(), 0, unquoted);