Author: gadamopoulos Date: Thu Feb 13 11:10:47 2014 New Revision: 62143
URL: http://svn.reactos.org/svn/reactos?rev=62143&view=rev Log: [shell32] - Implement showing the target type in shortcut properties dialog - Patch by Edijs Kolesnikovics - See CORE-7366
Modified: trunk/reactos/dll/win32/shell32/shelllink.cpp
Modified: trunk/reactos/dll/win32/shell32/shelllink.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/shelllink... ============================================================================== --- trunk/reactos/dll/win32/shell32/shelllink.cpp [iso-8859-1] (original) +++ trunk/reactos/dll/win32/shell32/shelllink.cpp [iso-8859-1] Thu Feb 13 11:10:47 2014 @@ -76,6 +76,43 @@
#include "poppack.h"
+/************************************************************************** +* SH_GetTargetTypeByPath +* +* Function to get target type by passing full path to it +*/ +LPWSTR SH_GetTargetTypeByPath(LPCWSTR lpcwFullPath) +{ + LPCWSTR pwszExt; + static WCHAR wszBuf[MAX_PATH]; + + /* Get file information */ + SHFILEINFO fi; + if (!SHGetFileInfoW(lpcwFullPath, 0, &fi, sizeof(fi), SHGFI_TYPENAME | SHGFI_USEFILEATTRIBUTES )) + { + ERR("SHGetFileInfoW failed for %ls (%lu)\n", lpcwFullPath, GetLastError()); + fi.szTypeName[0] = L'\0'; + fi.hIcon = NULL; + } + + pwszExt = PathFindExtensionW(lpcwFullPath); + if (pwszExt[0]) + { + if (!fi.szTypeName[0]) + { + /* The file type is unknown, so default to string "FileExtension File" */ + size_t cchRemaining = 0; + LPWSTR pwszEnd = NULL; + + StringCchPrintfExW(wszBuf, _countof(wszBuf), &pwszEnd, &cchRemaining, 0, L"%s ", pwszExt + 1); + } + else + StringCbPrintfW(wszBuf, sizeof(wszBuf), L"%s (%s)", fi.szTypeName, pwszExt); /* Update file type */ + } + + return wszBuf; +} + /* IShellLink Implementation */
static HRESULT ShellLink_UpdatePath(LPCWSTR sPathRel, LPCWSTR path, LPCWSTR sWorkDir, LPWSTR* psPath); @@ -1949,6 +1986,10 @@ else ERR("ExtractIconW failed %ls %u\n", pThis->sIcoPath, pThis->iIcoNdx);
+ /* target type */ + if (pThis->sPath) + SetDlgItemTextW(hwndDlg, 14005, SH_GetTargetTypeByPath(pThis->sPath)); + /* target location */ if (pThis->sWorkDir) SetDlgItemTextW(hwndDlg, 14007, PathFindFileName(pThis->sWorkDir));