Index: dll/cpl/appwiz/appwiz.h =================================================================== --- dll/cpl/appwiz/appwiz.h (revision 70157) +++ dll/cpl/appwiz/appwiz.h (working copy) @@ -4,6 +4,7 @@ #include #include +#include #include #define WIN32_NO_STATUS @@ -17,6 +18,7 @@ #include #include #include +#include #include WINE_DEFAULT_DEBUG_CHANNEL(appwiz); Index: dll/cpl/appwiz/CMakeLists.txt =================================================================== --- dll/cpl/appwiz/CMakeLists.txt (revision 70157) +++ dll/cpl/appwiz/CMakeLists.txt (working copy) @@ -22,7 +22,7 @@ set_module_type(appwiz cpl UNICODE) target_link_libraries(appwiz uuid wine) -add_importlibs(appwiz urlmon ole32 comctl32 advapi32 shell32 user32 msvcrt kernel32 ntdll) +add_importlibs(appwiz urlmon ole32 comctl32 advapi32 shlwapi shell32 user32 msvcrt kernel32 ntdll) add_delay_importlibs(appwiz msi) add_pch(appwiz appwiz.h SOURCE) add_cd_file(TARGET appwiz DESTINATION reactos/system32 FOR all) Index: dll/cpl/appwiz/createlink.c =================================================================== --- dll/cpl/appwiz/createlink.c (revision 70157) +++ dll/cpl/appwiz/createlink.c (working copy) @@ -70,7 +70,7 @@ } BOOL -CreateShortcut(PCREATE_LINK_CONTEXT pContext) +CreateShortcut(PCREATE_LINK_CONTEXT pContext, BOOL isUrl) { IShellLinkW *pShellLink, *pSourceShellLink; IPersistFile *pPersistFile; @@ -78,6 +78,29 @@ WCHAR Path[MAX_PATH]; LPWSTR lpExtension; + /* Determine if the target is a URL */ + if (isUrl) + { + FILE *hUrl; + WCHAR TargetPath[MAX_PATH]; + + /* Create the URL File */ + hUrl = _wfopen(pContext->szLinkName, L"a+,ccs=UTF-8"); + if (hUrl == NULL) + return FALSE; + + wcscpy(TargetPath, L"URL="); + wcscat(TargetPath, pContext->szTarget); + + /* Writes the content to the URL file */ + fputws(L"[InternetShortcut]\n", hUrl); + fputws(TargetPath, hUrl); + + fclose(hUrl); + + return TRUE; + } + /* get the extension */ lpExtension = wcsrchr(pContext->szTarget, '.'); @@ -218,7 +241,7 @@ /// FIXME /// it should also be possible to create a link to folders, shellobjects etc.... /// - if (GetFileAttributesW(pContext->szTarget) == INVALID_FILE_ATTRIBUTES) + if ((GetFileAttributesW(pContext->szTarget) == INVALID_FILE_ATTRIBUTES) && (!PathIsURLW(pContext->szTarget))) { szDesc[0] = L'\0'; szPath[0] = L'\0'; @@ -269,6 +292,7 @@ LPPROPSHEETPAGEW ppsp; PCREATE_LINK_CONTEXT pContext; LPPSHNOTIFY lppsn; + BOOL isURL = FALSE; switch(uMsg) { @@ -301,11 +325,45 @@ { SendDlgItemMessageW(hwndDlg, IDC_SHORTCUT_NAME, WM_GETTEXT, MAX_PATH, (LPARAM)pContext->szDescription); wcscat(pContext->szLinkName, pContext->szDescription); - wcscat(pContext->szLinkName, L".lnk"); - if (!CreateShortcut(pContext)) + + /* Find out if the target location is a URL or not */ + isURL = PathIsURLW(pContext->szTarget); + + /* Determine the file extension based on if the target location is a URL or not */ + wcscat(pContext->szLinkName, (isURL ? L".url" : L".lnk")); + + /* Find out if the shortcut already exists before continuing. + If so, then ask the user if they want to overwrite it. */ + if (GetFileAttributesW(pContext->szLinkName) != INVALID_FILE_ATTRIBUTES) { - MessageBox(hwndDlg, _T("Failed to create shortcut"), _T("Error"), MB_ICONERROR); + WCHAR szShortcutMsg[MAX_PATH], szCaption[MAX_PATH], szError[MAX_PATH + 100]; + + LoadStringW(hApplet, IDS_ERROR_SHORTCUT_EXISTS, szShortcutMsg, MAX_PATH); + LoadStringW(hApplet, IDS_SHORTCUT_FINISH, szCaption, MAX_PATH); + + swprintf(szError, szShortcutMsg, pContext->szLinkName); + + /* If the user does not want to overwrite the existing shortcut then just refocus + onto the shortcut name edit text box */ + if (MessageBoxW(hwndDlg, szError, szCaption, MB_YESNO | MB_ICONERROR) == IDNO) + { + SendDlgItemMessage(hwndDlg, IDC_SHORTCUT_NAME, EM_SETSEL, 0, -1); + SetFocus(GetDlgItem(hwndDlg, IDC_SHORTCUT_NAME)); + SetWindowLongPtr(hwndDlg, DWL_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE); + return -1; + } } + + /* Try to create the shortcut */ + if (!CreateShortcut(pContext, isURL)) + { + WCHAR szMessage[MAX_PATH], szCaption[MAX_PATH], szError[MAX_PATH]; + LoadStringW(hApplet, IDS_CREATE_SHORTCUT_FAILED, szMessage, MAX_PATH); + LoadStringW(hApplet, IDS_CREATE_SHORTCUT, szCaption, MAX_PATH); + swprintf(szError, szMessage, pContext->szTarget); + + MessageBoxW(hwndDlg, szError, szCaption, MB_OK | MB_ICONERROR); + } } Index: dll/cpl/appwiz/lang/en-US.rc =================================================================== --- dll/cpl/appwiz/lang/en-US.rc (revision 70157) +++ dll/cpl/appwiz/lang/en-US.rc (working copy) @@ -58,7 +58,10 @@ IDS_CPLSYSTEMNAME "Add/Remove Programs" IDS_CPLSYSTEMDESCRIPTION "Sets up programs and creates shortcuts." IDS_CREATE_SHORTCUT "Create Shortcut" + IDS_CREATE_SHORTCUT_FAILED "Failed to create shortcut." IDS_ERROR_NOT_FOUND "The file %s was not found." + IDS_ERROR_SHORTCUT_EXISTS "A shorcut named %s\nalready exists in this folder. Do you want to replace it?" + IDS_SHORTCUT_FINISH "Select a Title for the Program" END STRINGTABLE Index: dll/cpl/appwiz/resource.h =================================================================== --- dll/cpl/appwiz/resource.h (revision 70157) +++ dll/cpl/appwiz/resource.h (working copy) @@ -25,7 +25,10 @@ #define IDS_CPLSYSTEMNAME 1001 #define IDS_CPLSYSTEMDESCRIPTION 2001 #define IDS_CREATE_SHORTCUT 2021 -#define IDS_ERROR_NOT_FOUND 2022 +#define IDS_CREATE_SHORTCUT_FAILED 2022 +#define IDS_ERROR_NOT_FOUND 2023 +#define IDS_ERROR_SHORTCUT_EXISTS 2024 +#define IDS_SHORTCUT_FINISH 2025 #define IDS_DOWNLOADING 14 #define IDS_INSTALLING 15