mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 08:25:03 +00:00
[0.4.11] [SHELL32] Enable environment variables in 'Run' dialog (#1111)
CORE-15431 (1 of 2)
cherry picked from commit 0.4.12-dev-19-g
06d717e3bc
This commit is contained in:
parent
842671e219
commit
5aea1c7118
1 changed files with 26 additions and 5 deletions
|
@ -551,7 +551,8 @@ static INT_PTR CALLBACK RunDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARA
|
|||
LRESULT lRet;
|
||||
HWND htxt = GetDlgItem(hwnd, IDC_RUNDLG_EDITPATH);
|
||||
INT ic;
|
||||
WCHAR *psz, *parent = NULL;
|
||||
WCHAR *psz, *pszExpanded, *parent = NULL;
|
||||
DWORD cchExpand;
|
||||
NMRUNFILEDLGW nmrfd;
|
||||
|
||||
ic = GetWindowTextLengthW(htxt);
|
||||
|
@ -575,6 +576,24 @@ static INT_PTR CALLBACK RunDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARA
|
|||
GetWindowTextW(htxt, psz, ic + 1);
|
||||
StrTrimW(psz, L" \t");
|
||||
|
||||
if (wcschr(psz, L'%') != NULL)
|
||||
{
|
||||
cchExpand = ExpandEnvironmentStringsW(psz, NULL, 0);
|
||||
pszExpanded = (WCHAR*)HeapAlloc(GetProcessHeap(), 0, cchExpand * sizeof(WCHAR));
|
||||
if (!pszExpanded)
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, psz);
|
||||
EndDialog(hwnd, IDCANCEL);
|
||||
return TRUE;
|
||||
}
|
||||
ExpandEnvironmentStringsW(psz, pszExpanded, cchExpand);
|
||||
StrTrimW(pszExpanded, L" \t");
|
||||
}
|
||||
else
|
||||
{
|
||||
pszExpanded = psz;
|
||||
}
|
||||
|
||||
/*
|
||||
* The precedence is the following: first the user-given
|
||||
* current directory is used; if there is none, a current
|
||||
|
@ -604,7 +623,7 @@ static INT_PTR CALLBACK RunDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARA
|
|||
nmrfd.hdr.code = RFN_VALIDATE;
|
||||
nmrfd.hdr.hwndFrom = hwnd;
|
||||
nmrfd.hdr.idFrom = 0;
|
||||
nmrfd.lpFile = psz;
|
||||
nmrfd.lpFile = pszExpanded;
|
||||
nmrfd.lpDirectory = pszStartDir;
|
||||
nmrfd.nShow = SW_SHOWNORMAL;
|
||||
|
||||
|
@ -617,12 +636,12 @@ static INT_PTR CALLBACK RunDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARA
|
|||
break;
|
||||
|
||||
case RF_OK:
|
||||
if (SUCCEEDED(ShellExecCmdLine(hwnd, psz, pszStartDir, SW_SHOWNORMAL, NULL,
|
||||
if (SUCCEEDED(ShellExecCmdLine(hwnd, pszExpanded, pszStartDir, SW_SHOWNORMAL, NULL,
|
||||
SECL_ALLOW_NONEXE)))
|
||||
{
|
||||
/* Call again GetWindowText in case the contents of the edit box has changed? */
|
||||
GetWindowTextW(htxt, psz, ic + 1);
|
||||
FillList(htxt, psz, ic + 2 + 1, FALSE);
|
||||
GetWindowTextW(htxt, pszExpanded, ic + 1);
|
||||
FillList(htxt, pszExpanded, ic + 2 + 1, FALSE);
|
||||
EndDialog(hwnd, IDOK);
|
||||
break;
|
||||
}
|
||||
|
@ -638,6 +657,8 @@ static INT_PTR CALLBACK RunDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARA
|
|||
|
||||
HeapFree(GetProcessHeap(), 0, parent);
|
||||
HeapFree(GetProcessHeap(), 0, psz);
|
||||
if (psz != pszExpanded)
|
||||
HeapFree(GetProcessHeap(), 0, pszExpanded);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue