···294294 m_pDBList = NULL;
295295 m_bInInit = FALSE;
296296 m_hIcon = NULL;
297297- m_idCmdFirst = 0;
298297299298 m_sLinkPath = NULL;
300299···25432542{
25442543 INT id = 0;
2545254425462546- m_idCmdFirst = idCmdFirst;
25472547-25482545 TRACE("%p %p %u %u %u %u\n", this,
25492546 hMenu, indexMenu, idCmdFirst, idCmdLast, uFlags);
25502547···2934293129352932 case IDC_SHORTCUT_CHANGE_ICON:
29362933 {
29372937- WCHAR wszPath[MAX_PATH] = L"";
29342934+ SHFILEINFOW fi;
29352935+ INT IconIndex = m_Header.nIconIndex;
29362936+ WCHAR wszPath[MAX_PATH];
29372937+ *wszPath = UNICODE_NULL;
29382938+29392939+ if (!StrIsNullOrEmpty(m_sIcoPath))
29402940+ {
29412941+ PWSTR pszPath = m_sIcoPath;
29422942+ if (*m_sIcoPath == '.') // Extension-only icon location, we need a fake path
29432943+ {
29442944+ if (SUCCEEDED(StringCchPrintfW(wszPath, _countof(wszPath), L"x:\\x%s", m_sIcoPath)) &&
29452945+ SHGetFileInfoW(wszPath, 0, &fi, sizeof(fi), SHGFI_ICONLOCATION | SHGFI_USEFILEATTRIBUTES))
29462946+ {
29472947+ pszPath = fi.szDisplayName; // The path is now a generic icon based
29482948+ IconIndex = fi.iIcon; // on the registry info of the file extension.
29492949+ }
29502950+ }
2938295129392939- if (m_sIcoPath)
29402940- wcscpy(wszPath, m_sIcoPath);
29412941- else
29522952+ if (FAILED(StringCchCopyW(wszPath, _countof(wszPath), pszPath)))
29532953+ *wszPath = UNICODE_NULL;
29542954+ }
29552955+ else if (!StrIsNullOrEmpty(m_sPath))
29562956+ {
29422957 FindExecutableW(m_sPath, NULL, wszPath);
29582958+ }
2943295929442944- INT IconIndex = m_Header.nIconIndex;
29602960+ if (!*wszPath && m_pPidl)
29612961+ {
29622962+ if (SHGetFileInfoW((PWSTR)m_pPidl, 0, &fi, sizeof(fi), SHGFI_ICONLOCATION | SHGFI_PIDL) &&
29632963+ SUCCEEDED(StringCchCopyW(wszPath, _countof(wszPath), fi.szDisplayName)))
29642964+ {
29652965+ IconIndex = fi.iIcon;
29662966+ }
29672967+ }
29682968+29452969 if (PickIconDlg(hwndDlg, wszPath, _countof(wszPath), &IconIndex))
29462970 {
29472971 SetIconLocation(wszPath, IconIndex);
···29933017 SetWorkingDirectory(wszBuf);
2994301829953019 /* set link destination */
29962996- GetDlgItemTextW(hwndDlg, IDC_SHORTCUT_TARGET_TEXT, wszBuf, _countof(wszBuf));
29972997- LPWSTR lpszArgs = NULL;
29982998- LPWSTR unquoted = strdupW(wszBuf);
29992999- StrTrimW(unquoted, L" ");
30003000-30013001- if (!PathFileExistsW(unquoted))
30203020+ HWND hWndTarget = GetDlgItem(hwndDlg, IDC_SHORTCUT_TARGET_TEXT);
30213021+ GetWindowTextW(hWndTarget, wszBuf, _countof(wszBuf));
30223022+ // Only set the path and arguments for filesystem targets (we can't verify other targets)
30233023+ if (IsWindowEnabled(hWndTarget))
30023024 {
30033003- lpszArgs = PathGetArgsW(unquoted);
30043004- PathRemoveArgsW(unquoted);
30053005- StrTrimW(lpszArgs, L" ");
30063006- }
30073007- if (unquoted[0] == '"' && unquoted[wcslen(unquoted) - 1] == '"')
30083008- PathUnquoteSpacesW(unquoted);
30253025+ LPWSTR lpszArgs = NULL;
30263026+ LPWSTR unquoted = wszBuf;
30273027+ StrTrimW(unquoted, L" ");
3009302830103010- WCHAR *pwszExt = PathFindExtensionW(unquoted);
30113011- if (!_wcsicmp(pwszExt, L".lnk"))
30123012- {
30133013- // FIXME load localized error msg
30143014- MessageBoxW(hwndDlg, L"You cannot create a link to a shortcut", L"Error", MB_ICONERROR);
30153015- SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
30163016- return TRUE;
30173017- }
30293029+ if (!PathFileExistsW(unquoted))
30303030+ {
30313031+ lpszArgs = PathGetArgsW(unquoted);
30323032+ PathRemoveArgsW(unquoted);
30333033+ StrTrimW(lpszArgs, L" ");
30343034+ }
30353035+ if (unquoted[0] == '"' && unquoted[wcslen(unquoted) - 1] == '"')
30363036+ PathUnquoteSpacesW(unquoted);
3018303730193019- if (!PathFileExistsW(unquoted))
30203020- {
30213021- // FIXME load localized error msg
30223022- MessageBoxW(hwndDlg, L"The specified file name in the target box is invalid", L"Error", MB_ICONERROR);
30233023- SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
30243024- return TRUE;
30253025- }
30383038+ WCHAR *pwszExt = PathFindExtensionW(unquoted);
30393039+ if (!_wcsicmp(pwszExt, L".lnk"))
30403040+ {
30413041+ // TODO: SLDF_ALLOW_LINK_TO_LINK (Win7+)
30423042+ // FIXME load localized error msg
30433043+ MessageBoxW(hwndDlg, L"You cannot create a link to a shortcut", NULL, MB_ICONERROR);
30443044+ SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
30453045+ return TRUE;
30463046+ }
3026304730273027- SetPath(unquoted);
30283028- if (lpszArgs)
30293029- SetArguments(lpszArgs);
30303030- else
30313031- SetArguments(L"\0");
30483048+ if (!PathFileExistsW(unquoted))
30493049+ {
30503050+ // FIXME load localized error msg
30513051+ MessageBoxW(hwndDlg, L"The specified file name in the target box is invalid", NULL, MB_ICONERROR);
30523052+ SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
30533053+ return TRUE;
30543054+ }
3032305530333033- HeapFree(GetProcessHeap(), 0, unquoted);
30563056+ SetPath(unquoted);
30573057+ SetArguments(lpszArgs ? lpszArgs : L"\0");
30583058+ }
3034305930353060 m_Header.wHotKey = (WORD)SendDlgItemMessageW(hwndDlg, IDC_SHORTCUT_KEY_HOTKEY, HKM_GETHOTKEY, 0, 0);
30363061
-1
dll/win32/shell32/CShellLink.h
···8787 LPDBLIST m_pDBList; /* Optional data block list (in the extra data section) */
8888 BOOL m_bInInit; // in initialization or not
8989 HICON m_hIcon;
9090- UINT m_idCmdFirst;
91909291 /* Pointers to strings inside Logo3/Darwin info blocks, cached for debug info purposes only */
9392 LPWSTR sProduct;