Index: reactos/dll/win32/shell32/CShellLink.cpp =================================================================== --- reactos/dll/win32/shell32/CShellLink.cpp (revision 73458) +++ reactos/dll/win32/shell32/CShellLink.cpp (working copy) @@ -959,12 +959,19 @@ 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); - - return S_OK; + if (pfd) + { + CHAR szPath[MAX_PATH]; + WideCharToMultiByte(CP_ACP, 0, sPath, -1, + szPath, MAX_PATH, NULL, NULL); + FindClose(FindFirstFileA(szPath, pfd)); + } + } + return (sPath && sPath[0]) ? S_OK : S_FALSE; } HRESULT WINAPI CShellLink::GetIDList(LPITEMIDLIST * ppidl) @@ -972,26 +979,42 @@ 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; @@ -1181,11 +1204,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_PidlGeticonLocationA(pdsk, pidl, pszIconPath, cchIconPath, piIcon); @@ -1311,9 +1331,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) @@ -1469,11 +1490,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); @@ -1622,6 +1640,7 @@ { LPWSTR unquoted = NULL; HRESULT hr = S_OK; + LPITEMIDLIST pidl = NULL; TRACE("(%p)->(path=%s)\n", this, debugstr_w(pszFile)); @@ -1644,40 +1663,79 @@ 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]; - LPWSTR fname; + WCHAR Buff[MAX_PATH], PathExt[MAX_PATH], *pChar, *pExt, *FName; - if (*pszFile == '\0') - *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)) - hr = S_FALSE; + if (*pszFile == L'\0') + { + *Buff = L'\0'; + } + else if (!GetFullPathNameW(pszFile, _countof(Buff), Buff, &FName)) + { + return E_FAIL; // invalid path name + } + else if (!PathFileExistsW(Buff)) + { + if (GetEnvironmentVariable(TEXT("PATHEXT"), PathExt, + _countof(PathExt))) + { + pExt = PathExt; + hr = S_FALSE; // not found + for (;;) + { + pChar = wcschr(pExt, L';'); + if (pChar == NULL) + break; - pPidl = SHSimpleIDListFromPathW(pszFile); - ShellLink_GetVolumeInfo(buffer, &volume); + *pChar = 0; + if (*pExt == L'.' && + SearchPathW(NULL, pszFile, pExt, + _countof(Buff), Buff, NULL)) + { + hr = S_OK; // found + break; + } + pExt = pChar + 1; + } + if (*pExt == L'.' && + SearchPathW(NULL, pszFile, pExt, _countof(Buff), Buff, + NULL)) + { + hr = S_OK; // found + } + } + else + { + hr = S_FALSE; // not found + } + } - sPath = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, - (wcslen(buffer) + 1) * sizeof (WCHAR)); - if (!sPath) - return E_OUTOFMEMORY; + pidl = SHSimpleIDListFromPathW(Buff); + ShellLink_GetVolumeInfo(Buff, &volume); - wcscpy(sPath, buffer); + if (SUCCEEDED(hr)) + { + HeapFree(GetProcessHeap(), 0, sPath); + sPath = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, + (wcslen(Buff) + 1) * sizeof(WCHAR)); + if (!sPath) + return E_OUTOFMEMORY; + + wcscpy(sPath, Buff); + } } + if (SUCCEEDED(hr)) + { + if (pPidl) + ILFree(pPidl); + pPidl = pidl; + } + bDirty = TRUE; HeapFree(GetProcessHeap(), 0, unquoted);