@@ -290,11 +290,14 @@ void CMainWindow::UpdateCurrentFolder(PCUIDLIST_RELATIVE lpidl)
290290 }
291291}
292292
293- void CMainWindow::UpdateCurrentFolderAbsolute (PCUIDLIST_ABSOLUTE lpidl)
293+ void CMainWindow::UpdateCurrentFolderAbsolute (PCUIDLIST_ABSOLUTE lpidl, IShellFolder* pFolder )
294294{
295295 HRESULT hr;
296296
297- hr = m_wndListViewLocal.ReplaceViewAbsolute (lpidl);
297+ if (pFolder)
298+ hr = m_wndListViewLocal.ReplaceViewAbsolute (lpidl, pFolder);
299+ else
300+ hr = m_wndListViewLocal.ReplaceViewAbsolute (lpidl);
298301 if (SUCCEEDED (hr))
299302 {
300303 // ::SetWindowPos(m_wndListViewLocal, m_wndAddrButtons, 0, 0, 0, 0,
@@ -384,17 +387,14 @@ void CMainWindow::UpdateServerFolder(PCUIDLIST_RELATIVE lpidl)
384387 }
385388}
386389
387- void CMainWindow::UpdateServerFolderAbsolute (PCUIDLIST_ABSOLUTE lpidl)
390+ void CMainWindow::UpdateServerFolderAbsolute (PCUIDLIST_ABSOLUTE lpidl, IShellFolder* pFolder )
388391{
389392 HRESULT hr;
390- // IShellFolder* pFolder;
391393
392- // hr = theApp.m_pEasySFTPRoot->QueryInterface(IID_IShellFolder, (void**) &pFolder);
393- // if (FAILED(hr))
394- // return;
395- // hr = m_wndListViewServer.ReplaceViewAbsolute(lpidl, pFolder);
396- // pFolder->Release();
397- hr = m_wndListViewServer.ReplaceViewAbsolute (lpidl);
394+ if (pFolder)
395+ hr = m_wndListViewServer.ReplaceViewAbsolute (lpidl, pFolder);
396+ else
397+ hr = m_wndListViewServer.ReplaceViewAbsolute (lpidl);
398398 if (SUCCEEDED (hr))
399399 {
400400 // ::SetWindowPos(m_wndListViewServer, m_wndServerAddrButtons, 0, 0, 0, 0,
@@ -2459,7 +2459,7 @@ LRESULT CMainWindow::OnToolBarDropDown(WPARAM wParam, LPARAM lParam)
24592459 return TBDDRET_DEFAULT;
24602460}
24612461
2462- static PIDLIST_ABSOLUTE __stdcall GetEasySFTPItemIfAvailable (HWND hWnd, LPCWSTR lpszAddress)
2462+ static PIDLIST_ABSOLUTE __stdcall GetEasySFTPItemIfAvailable (HWND hWnd, LPCWSTR lpszAddress, IShellFolder** ppFolder )
24632463{
24642464 if (wcschr (lpszAddress, L' :' ) == NULL )
24652465 return NULL ;
@@ -2483,23 +2483,15 @@ static PIDLIST_ABSOLUTE __stdcall GetEasySFTPItemIfAvailable(HWND hWnd, LPCWSTR
24832483 pRoot->Release ();
24842484 if (pDir)
24852485 {
2486- // VARIANT_BOOL b1, b2;
2487- // int n1, n2;
2488- // BSTR bstr1, bstr2;
2489- // if (SUCCEEDED(pDir->GetHostInfo(&b1, &n1, &bstr1)))
2490- // {
2491- // if (pDirectoryCurrent && SUCCEEDED(pDirectoryCurrent->GetHostInfo(&b2, &n2, &bstr2)))
2492- // {
2493- // if (b1 == b2 && n1 == n2 && _wcsicmp(bstr1, bstr2) == 0)
2494- // pidlRet = ::AppendItemIDList(theApp.m_pidlEasySFTP, pidlRel);
2495- // ::SysFreeString(bstr2);
2496- // }
2497- // // ホストが一致しなくても sftp モードであれば IDLIST を生成して成功にする
2498- // if (!pidlRet && b1)
2499- pidlRet = ::AppendItemIDList (theApp.m_pidlEasySFTP , pidlRel);
2500- // ::SysFreeString(bstr1);
2501- // }
2502- // pDir->Release();
2486+ IEasySFTPFiles* pFiles;
2487+ // force connect
2488+ if (SUCCEEDED (pDir->get_Files (&pFiles)))
2489+ {
2490+ pidlRet = ::AppendItemIDList (theApp.m_pidlEasySFTP , pidlRel);
2491+ pFiles->Release ();
2492+ }
2493+ pDir->QueryInterface (IID_IShellFolder, reinterpret_cast <void **>(ppFolder));
2494+ pDir->Release ();
25032495 }
25042496 if (pidlRel)
25052497 ::CoTaskMemFree (pidlRel);
@@ -2517,10 +2509,12 @@ void CMainWindow::OnLocalAddressTextReturn(LPCWSTR lpszText)
25172509 UpdateCurrentFolderAbsolute (pidl);
25182510 return ;
25192511 }
2520- pidl = GetEasySFTPItemIfAvailable (m_hWnd, lpszText);
2512+ IShellFolder* pFolder;
2513+ pidl = GetEasySFTPItemIfAvailable (m_hWnd, lpszText, &pFolder);
25212514 if (pidl)
25222515 {
2523- UpdateCurrentFolderAbsolute (pidl);
2516+ UpdateCurrentFolderAbsolute (pidl, pFolder);
2517+ pFolder->Release ();
25242518 ::CoTaskMemFree (pidl);
25252519 return ;
25262520 }
@@ -2602,10 +2596,12 @@ void CMainWindow::OnServerAddressTextReturn(LPCWSTR lpszText)
26022596 UpdateServerFolderAbsolute (pidl);
26032597 return ;
26042598 }
2605- pidl = GetEasySFTPItemIfAvailable (m_hWnd, lpszText);
2599+ IShellFolder* pFolder;
2600+ pidl = GetEasySFTPItemIfAvailable (m_hWnd, lpszText, &pFolder);
26062601 if (pidl)
26072602 {
2608- UpdateServerFolderAbsolute (pidl);
2603+ UpdateServerFolderAbsolute (pidl, pFolder);
2604+ pFolder->Release ();
26092605 ::CoTaskMemFree (pidl);
26102606 return ;
26112607 }
0 commit comments