diff --git a/reactos/dll/win32/shell32/shelllink.cpp b/reactos/dll/win32/shell32/shelllink.cpp index d8e5580dedb..fd54ee719fe 100644 --- a/reactos/dll/win32/shell32/shelllink.cpp +++ b/reactos/dll/win32/shell32/shelllink.cpp @@ -76,6 +76,43 @@ struct volume_info #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 @@ INT_PTR CALLBACK CShellLink::SH_ShellLinkDlgProc(HWND hwndDlg, UINT uMsg, WPARAM 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));