The following function found on the net re-classes DirectUIHWND control into the familiar SysListView32. However the change is not propagated until you double-click on the list-view items, manually change directories.
Be aware that every time you go to a different directory then the list-view presented for that directory has a different handle, which makes the task of sub-classing the control a kind of 'challenging'.
I still have to figure how to restore the list-view with the following function and refreshing without having to use mouse double-clicks.
void RevertExplorerToListView(HWND explorerHandle)
{
IShellWindows* shellWindow;
if (SUCCEEDED(CoCreateInstance(CLSID_ShellWindows, NULL, CLSCTX_ALL, IID_IShellWindows,
reinterpret_cast<void**>(&shellWindow))))
{
VARIANT v;
V_VT(&v) = VT_I4;
IDispatch* dispatch;
BOOL found = FALSE;
for (V_I4(&v) = 0; !found && shellWindow->Item(v, &dispatch) == S_OK; V_I4(&v)++)
{
IWebBrowserApp* browserApp;
if (SUCCEEDED
(dispatch->QueryInterface(IID_IWebBrowserApp, reinterpret_cast<void**>(&browserApp))))
{
HWND appHandle;
if(SUCCEEDED
(browserApp->get_HWND(reinterpret_cast<LONG_PTR*>(&appHandle))) && appHandle == explorerHandle)
{
found = TRUE;
IServiceProvider* provider;
if (
SUCCEEDED(browserApp->QueryInterface(IID_IServiceProvider, reinterpret_cast<void**>(&provider))))
{
IShellBrowser* browser;
if (
SUCCEEDED(provider->QueryService(SID_STopLevelBrowser, IID_IShellBrowser, reinterpret_cast<void**>(&browser))))
{
IFolderViewOptions* options;
if (SUCCEEDED(browser->QueryInterface(IID_IFolderViewOptions,
reinterpret_cast<void**>(&options))))
{
if (FAILED(options->SetFolderViewOptions(FVO_VISTALAYOUT, FVO_VISTALAYOUT)))
{
}
options->Release();
}
browser->Release();
}
provider->Release();
}
}
browserApp->Release();
}
}
shellWindow->Release();
}
}