https://devblogs.microsoft.com/oldnewthing/20130318-00/?p=4933
| 90 | |
| 91 | // https://devblogs.microsoft.com/oldnewthing/20130318-00/?p=4933 |
| 92 | static HRESULT FindDesktopFolderView(REFIID riid, void** ppv) |
| 93 | { |
| 94 | HRESULT hr; |
| 95 | CComPtr<IShellWindows> spShellWindows; |
| 96 | if (FAILED(hr = spShellWindows.CoCreateInstance(CLSID_ShellWindows))) |
| 97 | return hr; |
| 98 | |
| 99 | CComVariant vtLoc(CSIDL_DESKTOP); |
| 100 | CComVariant vtEmpty; |
| 101 | long lhwnd; |
| 102 | CComPtr<IDispatch> spdisp; |
| 103 | if (FAILED(hr = spShellWindows->FindWindowSW( |
| 104 | &vtLoc, &vtEmpty, |
| 105 | SWC_DESKTOP, &lhwnd, SWFO_NEEDDISPATCH, &spdisp))) |
| 106 | return hr; |
| 107 | |
| 108 | CComPtr<IShellBrowser> spBrowser; |
| 109 | if (FAILED(hr = CComQIPtr<IServiceProvider>(spdisp)-> |
| 110 | QueryService(SID_STopLevelBrowser, |
| 111 | IID_PPV_ARGS(&spBrowser)))) |
| 112 | return hr; |
| 113 | |
| 114 | CComPtr<IShellView> spView; |
| 115 | if (FAILED(hr = spBrowser->QueryActiveShellView(&spView))) |
| 116 | return hr; |
| 117 | |
| 118 | return spView->QueryInterface(riid, ppv); |
| 119 | } |
| 120 | |
| 121 | // https://gitlab.com/tortoisegit/tortoisegit/-/merge_requests/187 |
| 122 | static HRESULT GetFolderView(IUnknown* pSite, IShellView** psv) |
no test coverage detected