mirror of
https://github.com/reactos/reactos.git
synced 2024-12-29 10:35:28 +00:00
[APPWIZ] Delete shortcut file upon user cancel (#2279)
If the user cancelled, then "Create shortcut" Wizard deletes the shortcut file. CORE-16534
This commit is contained in:
parent
b9426a3f0e
commit
afb0ae877c
1 changed files with 32 additions and 17 deletions
|
@ -190,6 +190,7 @@ WelcomeDlgProc(HWND hwndDlg,
|
||||||
WCHAR szDesc[100];
|
WCHAR szDesc[100];
|
||||||
BROWSEINFOW brws;
|
BROWSEINFOW brws;
|
||||||
LPITEMIDLIST pidllist;
|
LPITEMIDLIST pidllist;
|
||||||
|
LPWSTR pch;
|
||||||
|
|
||||||
switch(uMsg)
|
switch(uMsg)
|
||||||
{
|
{
|
||||||
|
@ -236,10 +237,9 @@ WelcomeDlgProc(HWND hwndDlg,
|
||||||
break;
|
break;
|
||||||
case WM_NOTIFY:
|
case WM_NOTIFY:
|
||||||
lppsn = (LPPSHNOTIFY) lParam;
|
lppsn = (LPPSHNOTIFY) lParam;
|
||||||
|
pContext = (PCREATE_LINK_CONTEXT)GetWindowLongPtr(hwndDlg, DWLP_USER);
|
||||||
if (lppsn->hdr.code == PSN_WIZNEXT)
|
if (lppsn->hdr.code == PSN_WIZNEXT)
|
||||||
{
|
{
|
||||||
LPWSTR pch;
|
|
||||||
pContext = (PCREATE_LINK_CONTEXT) GetWindowLongPtr(hwndDlg, DWLP_USER);
|
|
||||||
GetDlgItemTextW(hwndDlg, IDC_SHORTCUT_LOCATION, pContext->szTarget, _countof(pContext->szTarget));
|
GetDlgItemTextW(hwndDlg, IDC_SHORTCUT_LOCATION, pContext->szTarget, _countof(pContext->szTarget));
|
||||||
StrTrimW(pContext->szTarget, L" \t");
|
StrTrimW(pContext->szTarget, L" \t");
|
||||||
|
|
||||||
|
@ -278,6 +278,12 @@ WelcomeDlgProc(HWND hwndDlg,
|
||||||
MessageBoxW(hwndDlg, szError, szDesc, MB_ICONERROR);
|
MessageBoxW(hwndDlg, szError, szDesc, MB_ICONERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (lppsn->hdr.code == PSN_RESET)
|
||||||
|
{
|
||||||
|
/* The user has clicked [Cancel] */
|
||||||
|
DeleteFileW(pContext->szOldFile);
|
||||||
|
SHChangeNotify(SHCNE_DELETE, SHCNF_PATHW, pContext->szOldFile, NULL);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -293,6 +299,7 @@ FinishDlgProc(HWND hwndDlg,
|
||||||
LPPROPSHEETPAGEW ppsp;
|
LPPROPSHEETPAGEW ppsp;
|
||||||
PCREATE_LINK_CONTEXT pContext;
|
PCREATE_LINK_CONTEXT pContext;
|
||||||
LPPSHNOTIFY lppsn;
|
LPPSHNOTIFY lppsn;
|
||||||
|
LPWSTR pch;
|
||||||
|
|
||||||
switch(uMsg)
|
switch(uMsg)
|
||||||
{
|
{
|
||||||
|
@ -323,17 +330,12 @@ FinishDlgProc(HWND hwndDlg,
|
||||||
pContext = (PCREATE_LINK_CONTEXT) GetWindowLongPtr(hwndDlg, DWLP_USER);
|
pContext = (PCREATE_LINK_CONTEXT) GetWindowLongPtr(hwndDlg, DWLP_USER);
|
||||||
if (lppsn->hdr.code == PSN_WIZFINISH)
|
if (lppsn->hdr.code == PSN_WIZFINISH)
|
||||||
{
|
{
|
||||||
LPWSTR pch;
|
|
||||||
DWORD attrs;
|
|
||||||
GetDlgItemTextW(hwndDlg, IDC_SHORTCUT_NAME, pContext->szDescription, MAX_PATH);
|
GetDlgItemTextW(hwndDlg, IDC_SHORTCUT_NAME, pContext->szDescription, MAX_PATH);
|
||||||
StrTrimW(pContext->szDescription, L" \t");
|
StrTrimW(pContext->szDescription, L" \t");
|
||||||
|
|
||||||
/* if old shortcut file exists, then delete it now */
|
/* if old shortcut file exists, then delete it now */
|
||||||
attrs = GetFileAttributesW(pContext->szOldFile);
|
DeleteFileW(pContext->szOldFile);
|
||||||
if (attrs != INVALID_FILE_ATTRIBUTES && !(attrs & FILE_ATTRIBUTE_DIRECTORY))
|
SHChangeNotify(SHCNE_DELETE, SHCNF_PATHW, pContext->szOldFile, NULL);
|
||||||
{
|
|
||||||
DeleteFileW(pContext->szOldFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IsInternetLocation(pContext->szTarget))
|
if (IsInternetLocation(pContext->szTarget))
|
||||||
{
|
{
|
||||||
|
@ -376,6 +378,12 @@ FinishDlgProc(HWND hwndDlg,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (lppsn->hdr.code == PSN_RESET)
|
||||||
|
{
|
||||||
|
/* The user has clicked [Cancel] */
|
||||||
|
DeleteFileW(pContext->szOldFile);
|
||||||
|
SHChangeNotify(SHCNE_DELETE, SHCNF_PATHW, pContext->szOldFile, NULL);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -406,9 +414,9 @@ ShowCreateShortcutWizard(HWND hwndCPl, LPWSTR szPath)
|
||||||
PROPSHEETPAGE psp;
|
PROPSHEETPAGE psp;
|
||||||
UINT nPages = 0;
|
UINT nPages = 0;
|
||||||
UINT nLength;
|
UINT nLength;
|
||||||
DWORD attrs;
|
|
||||||
PCREATE_LINK_CONTEXT pContext;
|
PCREATE_LINK_CONTEXT pContext;
|
||||||
WCHAR szMessage[128];
|
WCHAR szMessage[128];
|
||||||
|
LPWSTR pch;
|
||||||
|
|
||||||
pContext = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pContext));
|
pContext = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pContext));
|
||||||
if (!pContext)
|
if (!pContext)
|
||||||
|
@ -430,8 +438,7 @@ ShowCreateShortcutWizard(HWND hwndCPl, LPWSTR szPath)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
attrs = GetFileAttributesW(szPath);
|
if (!PathFileExistsW(szPath))
|
||||||
if (attrs == INVALID_FILE_ATTRIBUTES)
|
|
||||||
{
|
{
|
||||||
HeapFree(GetProcessHeap(), 0, pContext);
|
HeapFree(GetProcessHeap(), 0, pContext);
|
||||||
|
|
||||||
|
@ -442,13 +449,21 @@ ShowCreateShortcutWizard(HWND hwndCPl, LPWSTR szPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* build the pContext->szOrigin and pContext->szOldFile */
|
/* build the pContext->szOrigin and pContext->szOldFile */
|
||||||
StringCchCopyW(pContext->szOrigin, _countof(pContext->szOrigin), szPath);
|
if (PathIsDirectoryW(szPath))
|
||||||
pContext->szOldFile[0] = 0;
|
|
||||||
if (!(attrs & FILE_ATTRIBUTE_DIRECTORY))
|
|
||||||
{
|
{
|
||||||
LPWSTR pch;
|
StringCchCopyW(pContext->szOrigin, _countof(pContext->szOrigin), szPath);
|
||||||
StringCchCopyW(pContext->szOldFile, _countof(pContext->szOldFile), szPath);
|
pContext->szOldFile[0] = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
StringCchCopyW(pContext->szOrigin, _countof(pContext->szOrigin), szPath);
|
||||||
pch = PathFindFileNameW(pContext->szOrigin);
|
pch = PathFindFileNameW(pContext->szOrigin);
|
||||||
|
if (pch && *pch)
|
||||||
|
*pch = 0;
|
||||||
|
|
||||||
|
StringCchCopyW(pContext->szOldFile, _countof(pContext->szOldFile), szPath);
|
||||||
|
|
||||||
|
pch = PathFindFileNameW(szPath);
|
||||||
if (pch && *pch)
|
if (pch && *pch)
|
||||||
{
|
{
|
||||||
/* build szDescription */
|
/* build szDescription */
|
||||||
|
|
Loading…
Reference in a new issue