From 57ba1bd2d40cbdb7472d29a707b1c3643c2ea717 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Tue, 17 Jan 2017 19:16:50 +0000 Subject: [PATCH] [SHELL32] - Use explicit unicode SHFILEINFOW structure (where needed); - In CFSExtractIcon_CreateInstance, use _countof instead of hardcoding the MAX_PATHs; add some FIXMEs about the 'flags' parameter; - Code formatting in CExtractIcon.cpp. svn path=/trunk/; revision=73570 --- reactos/dll/win32/shell32/CExtractIcon.cpp | 3 +- reactos/dll/win32/shell32/CNewMenu.cpp | 2 +- .../dll/win32/shell32/dialogs/filedefext.cpp | 2 +- reactos/dll/win32/shell32/folders.cpp | 35 +++++++++---------- 4 files changed, 20 insertions(+), 22 deletions(-) diff --git a/reactos/dll/win32/shell32/CExtractIcon.cpp b/reactos/dll/win32/shell32/CExtractIcon.cpp index 0727b0b8862..232d2c212fc 100644 --- a/reactos/dll/win32/shell32/CExtractIcon.cpp +++ b/reactos/dll/win32/shell32/CExtractIcon.cpp @@ -237,8 +237,7 @@ HRESULT STDMETHODCALLTYPE CExtractIcon::GetIconLocation( return E_OUTOFMEMORY; } - hr = GetIconLocation( - uFlags, szIconFileW, cchMax, piIndex, pwFlags); + hr = GetIconLocation(uFlags, szIconFileW, cchMax, piIndex, pwFlags); if (SUCCEEDED(hr) && cchMax > 0) if (0 == WideCharToMultiByte(CP_ACP, 0, szIconFileW, cchMax, szIconFile, cchMax, NULL, NULL)) hr = E_FAIL; diff --git a/reactos/dll/win32/shell32/CNewMenu.cpp b/reactos/dll/win32/shell32/CNewMenu.cpp index f8e29e50d16..8fc4d0c6112 100644 --- a/reactos/dll/win32/shell32/CNewMenu.cpp +++ b/reactos/dll/win32/shell32/CNewMenu.cpp @@ -138,7 +138,7 @@ CNewMenu::SHELLNEW_ITEM *CNewMenu::LoadItem(LPCWSTR pwszExt) if (!Types[i].pszName) return NULL; - SHFILEINFO fi; + SHFILEINFOW fi; if (!SHGetFileInfoW(pwszExt, FILE_ATTRIBUTE_NORMAL, &fi, sizeof(fi), SHGFI_USEFILEATTRIBUTES|SHGFI_TYPENAME|SHGFI_ICON|SHGFI_SMALLICON)) return NULL; diff --git a/reactos/dll/win32/shell32/dialogs/filedefext.cpp b/reactos/dll/win32/shell32/dialogs/filedefext.cpp index a749ee395f1..042faa38c3b 100644 --- a/reactos/dll/win32/shell32/dialogs/filedefext.cpp +++ b/reactos/dll/win32/shell32/dialogs/filedefext.cpp @@ -362,7 +362,7 @@ CFileDefExt::InitFileType(HWND hwndDlg) return FALSE; /* Get file information */ - SHFILEINFO fi; + SHFILEINFOW fi; if (!SHGetFileInfoW(m_wszPath, 0, &fi, sizeof(fi), SHGFI_TYPENAME|SHGFI_ICON)) { ERR("SHGetFileInfoW failed for %ls (%lu)\n", m_wszPath, GetLastError()); diff --git a/reactos/dll/win32/shell32/folders.cpp b/reactos/dll/win32/shell32/folders.cpp index 975a825a5d7..12c1d71663f 100644 --- a/reactos/dll/win32/shell32/folders.cpp +++ b/reactos/dll/win32/shell32/folders.cpp @@ -196,12 +196,12 @@ GetIconOverlay(LPCITEMIDLIST pidl, WCHAR * wTemp, int* pIndex) HRESULT CFSExtractIcon_CreateInstance(IShellFolder * psf, LPCITEMIDLIST pidl, REFIID iid, LPVOID * ppvOut) { - CComPtr initIcon; + CComPtr initIcon; HRESULT hr; - int icon_idx; - UINT flags; - CHAR sTemp[MAX_PATH]; - WCHAR wTemp[MAX_PATH]; + int icon_idx = 0; + UINT flags = 0; // FIXME: Use it! + CHAR sTemp[MAX_PATH] = ""; + WCHAR wTemp[MAX_PATH] = L""; hr = SHCreateDefaultExtractIcon(IID_PPV_ARG(IDefaultExtractIconInit,&initIcon)); if (FAILED(hr)) @@ -210,7 +210,7 @@ HRESULT CFSExtractIcon_CreateInstance(IShellFolder * psf, LPCITEMIDLIST pidl, RE if (_ILIsFolder (pidl)) { if (SUCCEEDED(getIconLocationForFolder(psf, - pidl, 0, wTemp, MAX_PATH, + pidl, 0, wTemp, _countof(wTemp), &icon_idx, &flags))) { @@ -221,21 +221,21 @@ HRESULT CFSExtractIcon_CreateInstance(IShellFolder * psf, LPCITEMIDLIST pidl, RE initIcon->SetShortcutIcon(wTemp, icon_idx); } if (SUCCEEDED(getIconLocationForFolder(psf, - pidl, GIL_DEFAULTICON, wTemp, MAX_PATH, + pidl, GIL_DEFAULTICON, wTemp, _countof(wTemp), &icon_idx, &flags))) { initIcon->SetDefaultIcon(wTemp, icon_idx); } // if (SUCCEEDED(getIconLocationForFolder(psf, - // pidl, GIL_FORSHORTCUT, wTemp, MAX_PATH, + // pidl, GIL_FORSHORTCUT, wTemp, _countof(wTemp), // &icon_idx, // &flags))) // { // initIcon->SetShortcutIcon(wTemp, icon_idx); // } if (SUCCEEDED(getIconLocationForFolder(psf, - pidl, GIL_OPENICON, wTemp, MAX_PATH, + pidl, GIL_OPENICON, wTemp, _countof(wTemp), &icon_idx, &flags))) { @@ -246,10 +246,10 @@ HRESULT CFSExtractIcon_CreateInstance(IShellFolder * psf, LPCITEMIDLIST pidl, RE { BOOL found = FALSE; - if (_ILGetExtension(pidl, sTemp, MAX_PATH)) + if (_ILGetExtension(pidl, sTemp, _countof(sTemp))) { - if (HCR_MapTypeToValueA(sTemp, sTemp, MAX_PATH, TRUE) - && HCR_GetIconA(sTemp, sTemp, NULL, MAX_PATH, &icon_idx)) + if (HCR_MapTypeToValueA(sTemp, sTemp, _countof(sTemp), TRUE) + && HCR_GetIconA(sTemp, sTemp, NULL, _countof(sTemp), &icon_idx)) { if (!lstrcmpA("%1", sTemp)) /* icon is in the file */ { @@ -258,7 +258,7 @@ HRESULT CFSExtractIcon_CreateInstance(IShellFolder * psf, LPCITEMIDLIST pidl, RE } else { - MultiByteToWideChar(CP_ACP, 0, sTemp, -1, wTemp, MAX_PATH); + MultiByteToWideChar(CP_ACP, 0, sTemp, -1, wTemp, _countof(wTemp)); } found = TRUE; @@ -266,21 +266,20 @@ HRESULT CFSExtractIcon_CreateInstance(IShellFolder * psf, LPCITEMIDLIST pidl, RE else if (!lstrcmpiA(sTemp, "lnkfile")) { /* extract icon from shell shortcut */ - CComPtr psl; + CComPtr psl; HRESULT hr = psf->GetUIObjectOf(NULL, 1, &pidl, IID_NULL_PPV_ARG(IShellLinkW, &psl)); - if (SUCCEEDED(hr)) { - hr = psl->GetIconLocation(wTemp, MAX_PATH, &icon_idx); + hr = psl->GetIconLocation(wTemp, _countof(wTemp), &icon_idx); - if (SUCCEEDED(hr) && *sTemp) + if (SUCCEEDED(hr) && *wTemp) found = TRUE; - } } } + /* FIXME: We should normally use the correct icon format according to 'flags' */ if (!found) /* default icon */ initIcon->SetNormalIcon(swShell32Name, 0);