mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-09-02 04:13:34 +00:00
eliminated SHBindToParent()
svn path=/trunk/; revision=7426
This commit is contained in:
@@ -176,72 +176,58 @@ void FindProgramDlg::Refresh(bool delete_cache)
|
||||
void FindProgramDlg::collect_programs_callback(Entry* entry, void* param)
|
||||
{
|
||||
FindProgramDlg* pThis = (FindProgramDlg*) param;
|
||||
ShellPath shell_path;
|
||||
|
||||
if (!get_entry_pidl(entry, shell_path))
|
||||
return;
|
||||
|
||||
IShellLink* pShellLink;
|
||||
LPCITEMIDLIST pidl_last = NULL;
|
||||
IShellFolder* pFolder;
|
||||
|
||||
static DynamicFct<HRESULT(WINAPI*)(LPCITEMIDLIST, REFIID, LPVOID*, LPCITEMIDLIST*)> SHBindToParent(TEXT("SHELL32"), "SHBindToParent");
|
||||
|
||||
if (!SHBindToParent)
|
||||
return;
|
||||
|
||||
HRESULT hr = (*SHBindToParent)(shell_path, IID_IShellFolder, (LPVOID*)&pFolder, &pidl_last);
|
||||
HRESULT hr = entry->GetUIObjectOf(pThis->_hwnd, IID_IShellLink, (LPVOID*)&pShellLink);
|
||||
|
||||
if (SUCCEEDED(hr)) {
|
||||
hr = pFolder->GetUIObjectOf(pThis->_hwnd, 1, &pidl_last, IID_IShellLink, NULL, (LPVOID*)&pShellLink);
|
||||
ShellLinkPtr shell_link(pShellLink);
|
||||
|
||||
if (SUCCEEDED(hr)) {
|
||||
ShellLinkPtr shell_link(pShellLink);
|
||||
shell_link->Release();
|
||||
|
||||
/*hr = pShellLink->Resolve(pThis->_hwnd, SLR_NO_UI);
|
||||
if (SUCCEEDED(hr))*/ {
|
||||
WIN32_FIND_DATA wfd;
|
||||
TCHAR path[MAX_PATH];
|
||||
/*hr = pShellLink->Resolve(pThis->_hwnd, SLR_NO_UI);
|
||||
if (SUCCEEDED(hr))*/ {
|
||||
WIN32_FIND_DATA wfd;
|
||||
TCHAR path[MAX_PATH];
|
||||
|
||||
hr = pShellLink->GetPath(path, MAX_PATH-1, &wfd, SLGP_UNCPRIORITY);
|
||||
hr = pShellLink->GetPath(path, MAX_PATH-1, &wfd, SLGP_UNCPRIORITY);
|
||||
|
||||
if (SUCCEEDED(hr)) {
|
||||
TCHAR entry_path[MAX_PATH];
|
||||
if (SUCCEEDED(hr)) {
|
||||
TCHAR entry_path[MAX_PATH];
|
||||
|
||||
entry->get_path(entry_path);
|
||||
entry->get_path(entry_path);
|
||||
|
||||
String menu_path;
|
||||
String menu_path;
|
||||
|
||||
int len = pThis->_common_programs.size();
|
||||
int len = pThis->_common_programs.size();
|
||||
|
||||
if (len && !_tcsnicmp(entry_path, pThis->_common_programs, len))
|
||||
menu_path = ResString(IDS_ALL_USERS) + (String(entry_path)+len);
|
||||
else if ((len=pThis->_user_programs.size()) && !_tcsnicmp(entry_path, pThis->_user_programs, len))
|
||||
menu_path = String(entry_path)+len;
|
||||
if (len && !_tcsnicmp(entry_path, pThis->_common_programs, len))
|
||||
menu_path = ResString(IDS_ALL_USERS) + (String(entry_path)+len);
|
||||
else if ((len=pThis->_user_programs.size()) && !_tcsnicmp(entry_path, pThis->_user_programs, len))
|
||||
menu_path = String(entry_path)+len;
|
||||
|
||||
// store info in cache
|
||||
FPDEntry new_entry;
|
||||
// store info in cache
|
||||
FPDEntry new_entry;
|
||||
|
||||
new_entry._entry = entry;
|
||||
new_entry._menu_path = menu_path;
|
||||
new_entry._path = path;
|
||||
new_entry._entry = entry;
|
||||
new_entry._menu_path = menu_path;
|
||||
new_entry._path = path;
|
||||
|
||||
if (entry->_hIcon != (HICON)-1)
|
||||
new_entry._idxIcon = ImageList_AddIcon(pThis->_himl, entry->_hIcon);
|
||||
else
|
||||
new_entry._idxIcon = pThis->_idxNoIcon;
|
||||
if (entry->_hIcon != (HICON)-1)
|
||||
new_entry._idxIcon = ImageList_AddIcon(pThis->_himl, entry->_hIcon);
|
||||
else
|
||||
new_entry._idxIcon = pThis->_idxNoIcon;
|
||||
|
||||
pThis->_cache.push_front(new_entry);
|
||||
FPDEntry& cache_entry = pThis->_cache.front();
|
||||
pThis->_cache.push_front(new_entry);
|
||||
FPDEntry& cache_entry = pThis->_cache.front();
|
||||
|
||||
Lock lock(pThis->_thread._crit_sect);
|
||||
Lock lock(pThis->_thread._crit_sect);
|
||||
|
||||
// resolve deadlocks while executing Thread::Stop()
|
||||
if (!pThis->_thread.is_alive())
|
||||
return;
|
||||
// resolve deadlocks while executing Thread::Stop()
|
||||
if (!pThis->_thread.is_alive())
|
||||
return;
|
||||
|
||||
pThis->add_entry(cache_entry);
|
||||
}
|
||||
pThis->add_entry(cache_entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -307,6 +307,59 @@ BOOL Entry::launch_entry(HWND hwnd, UINT nCmdShow)
|
||||
}
|
||||
|
||||
|
||||
HRESULT Entry::GetUIObjectOf(HWND hWnd, REFIID riid, LPVOID* ppvOut)
|
||||
{
|
||||
TCHAR path[MAX_PATH];
|
||||
/*
|
||||
if (!get_path(path))
|
||||
return E_FAIL;
|
||||
|
||||
ShellPath shell_path(path);
|
||||
|
||||
IShellFolder* pFolder;
|
||||
LPCITEMIDLIST pidl_last = NULL;
|
||||
|
||||
static DynamicFct<HRESULT(WINAPI*)(LPCITEMIDLIST, REFIID, LPVOID*, LPCITEMIDLIST*)> SHBindToParent(TEXT("SHELL32"), "SHBindToParent");
|
||||
|
||||
if (!SHBindToParent)
|
||||
return E_NOTIMPL;
|
||||
|
||||
HRESULT hr = (*SHBindToParent)(shell_path, IID_IShellFolder, (LPVOID*)&pFolder, &pidl_last);
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
|
||||
ShellFolder shell_folder(pFolder);
|
||||
|
||||
shell_folder->Release();
|
||||
|
||||
return shell_folder->GetUIObjectOf(hWnd, 1, &pidl_last, riid, NULL, ppvOut);
|
||||
*/
|
||||
if (!_up)
|
||||
return E_INVALIDARG;
|
||||
|
||||
if (!_up->get_path(path))
|
||||
return E_FAIL;
|
||||
|
||||
ShellPath shell_path(path);
|
||||
ShellFolder shell_folder(shell_path);
|
||||
|
||||
WCHAR wname[MAX_PATH];
|
||||
MultiByteToWideChar(CP_ACP, 0, _data.cFileName, -1, wname, MAX_PATH);
|
||||
|
||||
LPITEMIDLIST pidl_last = NULL;
|
||||
HRESULT hr = shell_folder->ParseDisplayName(hWnd, NULL, wname, NULL, &pidl_last, NULL);
|
||||
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
|
||||
hr = shell_folder->GetUIObjectOf(hWnd, 1, (LPCITEMIDLIST*)&pidl_last, riid, NULL, ppvOut);
|
||||
|
||||
ShellMalloc()->Free((void*)pidl_last);
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
||||
// recursively free all child entries
|
||||
void Entry::free_subentries()
|
||||
{
|
||||
|
||||
@@ -91,6 +91,7 @@ public:
|
||||
virtual const void* get_next_path_component(const void*) {return NULL;}
|
||||
virtual Entry* find_entry(const void*) {return NULL;}
|
||||
virtual bool get_path(PTSTR path) const = 0;
|
||||
virtual HRESULT GetUIObjectOf(HWND hWnd, REFIID riid, LPVOID* ppvOut);
|
||||
virtual BOOL launch_entry(HWND hwnd, UINT nCmdShow=SW_SHOWNORMAL);
|
||||
};
|
||||
|
||||
|
||||
@@ -151,6 +151,14 @@ bool ShellEntry::get_path(PTSTR path) const
|
||||
}
|
||||
|
||||
|
||||
HRESULT ShellEntry::GetUIObjectOf(HWND hWnd, REFIID riid, LPVOID* ppvOut)
|
||||
{
|
||||
LPCITEMIDLIST pidl = _pidl;
|
||||
|
||||
return get_parent_folder()->GetUIObjectOf(hWnd, 1, &pidl, riid, NULL, ppvOut);
|
||||
}
|
||||
|
||||
|
||||
// get full path of a shell folder
|
||||
bool ShellDirectory::get_path(PTSTR path) const
|
||||
{
|
||||
@@ -388,7 +396,6 @@ void ShellDirectory::read_directory(int scan_flags)
|
||||
|
||||
if (ext) {//@@
|
||||
int len = ext - entry->_data.cFileName;
|
||||
|
||||
entry->_display_name = (LPTSTR) malloc((len+1)*sizeof(TCHAR));
|
||||
_tcsncpy(entry->_display_name, entry->_data.cFileName, len);
|
||||
entry->_display_name[len] = TEXT('\0');
|
||||
|
||||
@@ -34,6 +34,7 @@ struct ShellEntry : public Entry
|
||||
|
||||
virtual bool get_path(PTSTR path) const;
|
||||
virtual BOOL launch_entry(HWND hwnd, UINT nCmdShow=SW_SHOWNORMAL);
|
||||
virtual HRESULT GetUIObjectOf(HWND hWnd, REFIID riid, LPVOID* ppvOut);
|
||||
|
||||
IShellFolder* get_parent_folder() const;
|
||||
ShellPath create_absolute_pidl() const;
|
||||
|
||||
Reference in New Issue
Block a user