Fix shell_open not returning errors on Windows

(cherry picked from commit c4787a8e6d)
This commit is contained in:
Ricardo Subtil 2021-09-19 11:29:56 +01:00 committed by Rémi Verschelde
parent 6702e37a88
commit 5167a0281a
No known key found for this signature in database
GPG key ID: C3336907360768E1

View file

@ -3083,8 +3083,27 @@ void OS_Windows::move_window_to_foreground() {
}
Error OS_Windows::shell_open(String p_uri) {
ShellExecuteW(NULL, NULL, p_uri.c_str(), NULL, NULL, SW_SHOWNORMAL);
return OK;
INT_PTR ret = (INT_PTR)ShellExecuteW(nullptr, nullptr, p_uri.c_str(), nullptr, nullptr, SW_SHOWNORMAL);
if (ret > 32) {
return OK;
} else {
switch (ret) {
case ERROR_FILE_NOT_FOUND:
case SE_ERR_DLLNOTFOUND:
return ERR_FILE_NOT_FOUND;
case ERROR_PATH_NOT_FOUND:
return ERR_FILE_BAD_PATH;
case ERROR_BAD_FORMAT:
return ERR_FILE_CORRUPT;
case SE_ERR_ACCESSDENIED:
return ERR_UNAUTHORIZED;
case 0:
case SE_ERR_OOM:
return ERR_OUT_OF_MEMORY;
default:
return FAILED;
}
}
}
String OS_Windows::get_locale() const {