diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-09-21 11:26:58 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-21 11:26:58 +0200 |
commit | a412011be7ebe5e0147b61ea37c08e4ab109a57a (patch) | |
tree | 9bfe99d73143e2abb9f0b2b5396dd9b9c5be3ac1 | |
parent | 2785ad32df15d8bd7aa9e9e7639994ee2c3c8826 (diff) | |
parent | c4787a8e6deaf13c838562db8fd4739c4d66b86c (diff) |
Merge pull request #52842 from Ev1lbl0w/fix_win_open_errcode
Fix shell_open not returning errors on Windows
-rw-r--r-- | platform/windows/os_windows.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 2a0a509d43..78b7be8a30 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -557,8 +557,27 @@ String OS_Windows::get_stdin_string(bool p_block) { } Error OS_Windows::shell_open(String p_uri) { - ShellExecuteW(nullptr, nullptr, (LPCWSTR)(p_uri.utf16().get_data()), nullptr, nullptr, SW_SHOWNORMAL); - return OK; + INT_PTR ret = (INT_PTR)ShellExecuteW(nullptr, nullptr, (LPCWSTR)(p_uri.utf16().get_data()), 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 { |