[BROWSEUI] Display an error message if the path or drive don't exist (CORE-10989)

The return result of ParseNow was never checked, but contained useful information on what type of error may have occurred.  If the error is an issue with the path not existing the explorer will now show an error message notifying the user of the problem instead of silently failing.
Note:  Shell32 does not properly return ERROR_INVALID_DRIVE when the drive path does not exist.  For that reason, it is still possible to browse to a non-existent drive.  However, once shell32 is patched this code will work properly, as it checks for both ERROR_INVALID_DRIVE and ERROR_FILE_NOT_FOUND.
This commit is contained in:
Charles Ambrye 2020-04-19 12:48:14 -07:00 committed by Giannis Adamopoulos
parent b8f4f22ba2
commit d8e47d61d4
25 changed files with 156 additions and 1 deletions

View file

@ -174,6 +174,19 @@ cleanup:
return hr;
}
HRESULT STDMETHODCALLTYPE CAddressEditBox::ShowFileNotFoundError(HRESULT hRet)
{
CComHeapPtr<WCHAR> input;
int inputLength = fCombobox.GetWindowTextLength() + 2;
input.Allocate(inputLength);
fCombobox.GetWindowText(input, inputLength);
ShellMessageBoxW(_AtlBaseModule.GetResourceInstance(), fCombobox.m_hWnd, MAKEINTRESOURCEW(IDS_PARSE_ADDR_ERR_TEXT), MAKEINTRESOURCEW(IDS_PARSE_ADDR_ERR_TITLE), MB_OK | MB_ICONERROR, input.m_pData);
return hRet;
}
HRESULT STDMETHODCALLTYPE CAddressEditBox::Execute(long paramC)
{
HRESULT hr;
@ -182,7 +195,13 @@ HRESULT STDMETHODCALLTYPE CAddressEditBox::Execute(long paramC)
* Parse the path is it wasn't parsed
*/
if (!pidlLastParsed)
ParseNow(0);
hr = ParseNow(0);
/*
* If the destination path doesn't exist then display an error message
*/
if (hr == HRESULT_FROM_WIN32(ERROR_INVALID_DRIVE) || hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND))
return ShowFileNotFoundError(hr);
if (!pidlLastParsed)
return E_FAIL;

View file

@ -47,6 +47,7 @@ private:
void AddComboBoxItem(LPITEMIDLIST pidl, int index, int indent);
void FillOneLevel(int index, int levelIndent, int indent);
LPITEMIDLIST GetItemData(int index);
HRESULT STDMETHODCALLTYPE ShowFileNotFoundError(HRESULT hRet);
public:
// *** IShellService methods ***
virtual HRESULT STDMETHODCALLTYPE SetOwner(IUnknown *);

View file

@ -336,3 +336,9 @@ BEGIN
IDS_COL_LOCATION "In Folder"
IDS_COL_RELEVANCE "Relevance"
END
STRINGTABLE
BEGIN
IDS_PARSE_ADDR_ERR_TITLE "ReactOS Explorer"
IDS_PARSE_ADDR_ERR_TEXT "ReactOS Explorer cannot find '%1'. Check the spelling and try again."
END

View file

@ -355,3 +355,9 @@ BEGIN
IDS_COL_LOCATION "In Ordner"
IDS_COL_RELEVANCE "Relevanz"
END
STRINGTABLE
BEGIN
IDS_PARSE_ADDR_ERR_TITLE "ReactOS Explorer"
IDS_PARSE_ADDR_ERR_TEXT "ReactOS Explorer cannot find '%1'. Check the spelling and try again."
END

View file

@ -354,3 +354,9 @@ BEGIN
IDS_COL_LOCATION "In Folder"
IDS_COL_RELEVANCE "Relevance"
END
STRINGTABLE
BEGIN
IDS_PARSE_ADDR_ERR_TITLE "ReactOS Explorer"
IDS_PARSE_ADDR_ERR_TEXT "ReactOS Explorer cannot find '%1'. Check the spelling and try again."
END

View file

@ -345,3 +345,9 @@ BEGIN
IDS_COL_LOCATION "En la carpeta"
IDS_COL_RELEVANCE "Relevancia"
END
STRINGTABLE
BEGIN
IDS_PARSE_ADDR_ERR_TITLE "ReactOS Explorer"
IDS_PARSE_ADDR_ERR_TEXT "ReactOS Explorer cannot find '%1'. Check the spelling and try again."
END

View file

@ -343,3 +343,9 @@ BEGIN
IDS_COL_LOCATION "In Folder"
IDS_COL_RELEVANCE "Relevance"
END
STRINGTABLE
BEGIN
IDS_PARSE_ADDR_ERR_TITLE "ReactOS Explorer"
IDS_PARSE_ADDR_ERR_TEXT "ReactOS Explorer cannot find '%1'. Check the spelling and try again."
END

View file

@ -354,3 +354,9 @@ BEGIN
IDS_COL_LOCATION "Dans le dossier"
IDS_COL_RELEVANCE "Pertinence"
END
STRINGTABLE
BEGIN
IDS_PARSE_ADDR_ERR_TITLE "Explorateur ReactOS"
IDS_PARSE_ADDR_ERR_TEXT "L'explorateur ReactOS ne peut trouver '%1'. Veuillez vérifier l'orthographe et réessayer."
END

View file

@ -338,3 +338,9 @@ BEGIN
IDS_COL_LOCATION "בתיקיה"
IDS_COL_RELEVANCE "רלוונטיות"
END
STRINGTABLE
BEGIN
IDS_PARSE_ADDR_ERR_TITLE "ReactOS Explorer"
IDS_PARSE_ADDR_ERR_TEXT "ReactOS Explorer cannot find '%1'. Check the spelling and try again."
END

View file

@ -336,3 +336,9 @@ BEGIN
IDS_COL_LOCATION "In Folder"
IDS_COL_RELEVANCE "Relevance"
END
STRINGTABLE
BEGIN
IDS_PARSE_ADDR_ERR_TITLE "ReactOS Explorer"
IDS_PARSE_ADDR_ERR_TEXT "ReactOS Explorer cannot find '%1'. Check the spelling and try again."
END

View file

@ -354,3 +354,9 @@ BEGIN
IDS_COL_LOCATION "In Folder"
IDS_COL_RELEVANCE "Relevance"
END
STRINGTABLE
BEGIN
IDS_PARSE_ADDR_ERR_TITLE "ReactOS Explorer"
IDS_PARSE_ADDR_ERR_TEXT "ReactOS Explorer cannot find '%1'. Check the spelling and try again."
END

View file

@ -354,3 +354,9 @@ BEGIN
IDS_COL_LOCATION "Dalam Folder"
IDS_COL_RELEVANCE "Relevansi"
END
STRINGTABLE
BEGIN
IDS_PARSE_ADDR_ERR_TITLE "ReactOS Explorer"
IDS_PARSE_ADDR_ERR_TEXT "ReactOS Explorer cannot find '%1'. Check the spelling and try again."
END

View file

@ -336,3 +336,9 @@ BEGIN
IDS_COL_LOCATION "In Folder"
IDS_COL_RELEVANCE "Relevance"
END
STRINGTABLE
BEGIN
IDS_PARSE_ADDR_ERR_TITLE "ReactOS Explorer"
IDS_PARSE_ADDR_ERR_TEXT "ReactOS Explorer cannot find '%1'. Check the spelling and try again."
END

View file

@ -354,3 +354,9 @@ BEGIN
IDS_COL_LOCATION "場所"
IDS_COL_RELEVANCE "関連"
END
STRINGTABLE
BEGIN
IDS_PARSE_ADDR_ERR_TITLE "ReactOS Explorer"
IDS_PARSE_ADDR_ERR_TEXT "ReactOS Explorer cannot find '%1'. Check the spelling and try again."
END

View file

@ -344,3 +344,9 @@ BEGIN
IDS_COL_LOCATION "W folderze"
IDS_COL_RELEVANCE "Istotność"
END
STRINGTABLE
BEGIN
IDS_PARSE_ADDR_ERR_TITLE "ReactOS Explorer"
IDS_PARSE_ADDR_ERR_TEXT "ReactOS Explorer cannot find '%1'. Check the spelling and try again."
END

View file

@ -338,3 +338,9 @@ BEGIN
IDS_COL_LOCATION "In Folder"
IDS_COL_RELEVANCE "Relevance"
END
STRINGTABLE
BEGIN
IDS_PARSE_ADDR_ERR_TITLE "ReactOS Explorer"
IDS_PARSE_ADDR_ERR_TEXT "ReactOS Explorer cannot find '%1'. Check the spelling and try again."
END

View file

@ -338,3 +338,9 @@ BEGIN
IDS_COL_LOCATION "In Folder"
IDS_COL_RELEVANCE "Relevance"
END
STRINGTABLE
BEGIN
IDS_PARSE_ADDR_ERR_TITLE "ReactOS Explorer"
IDS_PARSE_ADDR_ERR_TEXT "ReactOS Explorer cannot find '%1'. Check the spelling and try again."
END

View file

@ -338,3 +338,9 @@ BEGIN
IDS_COL_LOCATION "In Folder"
IDS_COL_RELEVANCE "Relevance"
END
STRINGTABLE
BEGIN
IDS_PARSE_ADDR_ERR_TITLE "ReactOS Explorer"
IDS_PARSE_ADDR_ERR_TEXT "ReactOS Explorer cannot find '%1'. Check the spelling and try again."
END

View file

@ -345,3 +345,9 @@ BEGIN
IDS_COL_LOCATION "В папке"
IDS_COL_RELEVANCE "Релевантность"
END
STRINGTABLE
BEGIN
IDS_PARSE_ADDR_ERR_TITLE "ReactOS Explorer"
IDS_PARSE_ADDR_ERR_TEXT "ReactOS Explorer cannot find '%1'. Check the spelling and try again."
END

View file

@ -355,3 +355,9 @@ BEGIN
IDS_COL_LOCATION "In Folder"
IDS_COL_RELEVANCE "Relevance"
END
STRINGTABLE
BEGIN
IDS_PARSE_ADDR_ERR_TITLE "ReactOS Explorer"
IDS_PARSE_ADDR_ERR_TEXT "ReactOS Explorer cannot find '%1'. Check the spelling and try again."
END

View file

@ -338,3 +338,9 @@ BEGIN
IDS_COL_LOCATION "In Folder"
IDS_COL_RELEVANCE "Relevance"
END
STRINGTABLE
BEGIN
IDS_PARSE_ADDR_ERR_TITLE "ReactOS Explorer"
IDS_PARSE_ADDR_ERR_TEXT "ReactOS Explorer cannot find '%1'. Check the spelling and try again."
END

View file

@ -344,3 +344,9 @@ BEGIN
IDS_COL_LOCATION "In Folder"
IDS_COL_RELEVANCE "Relevance"
END
STRINGTABLE
BEGIN
IDS_PARSE_ADDR_ERR_TITLE "ReactOS Explorer"
IDS_PARSE_ADDR_ERR_TEXT "ReactOS Explorer cannot find '%1'. Check the spelling and try again."
END

View file

@ -357,3 +357,9 @@ BEGIN
IDS_COL_LOCATION "In Folder"
IDS_COL_RELEVANCE "Relevance"
END
STRINGTABLE
BEGIN
IDS_PARSE_ADDR_ERR_TITLE "ReactOS Explorer"
IDS_PARSE_ADDR_ERR_TEXT "ReactOS Explorer cannot find '%1'. Check the spelling and try again."
END

View file

@ -357,3 +357,9 @@ BEGIN
IDS_COL_LOCATION "In Folder"
IDS_COL_RELEVANCE "Relevance"
END
STRINGTABLE
BEGIN
IDS_PARSE_ADDR_ERR_TITLE "ReactOS Explorer"
IDS_PARSE_ADDR_ERR_TEXT "ReactOS Explorer cannot find '%1'. Check the spelling and try again."
END

View file

@ -173,3 +173,6 @@
#define IDS_SEARCH_FOLDER 9234
#define IDS_SEARCH_RESULTS 30520
#define IDS_SEARCH_OPEN_FOLDER 40960
#define IDS_PARSE_ADDR_ERR_TITLE 9600
#define IDS_PARSE_ADDR_ERR_TEXT 9601