mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-10 20:01:25 +00:00
WIN32: Migrate from ShellExecute to ShellExecuteEx Function
That function allows more readable code, without needing to test if the returned value is greater than 32. Supported platforms are: Windows 95: Supported. Windows 98: Supported. Windows NT: Required Windows NT 4.0 or later. Windows 2000 and newer: Supported. Windows CE: Requires Windows CE 1.0 or later. This fix comes from my port of SCUMMVM for Windows CE/Embedded/Mobile since this family of OSs support ShellExecuteEx(), but not ShellExecute().
This commit is contained in:
parent
a83ce7d609
commit
b195cbbcd0
@ -159,8 +159,15 @@ bool OSystem_Win32::displayLogFile() {
|
||||
// Try opening the log file with the default text editor
|
||||
// log files should be registered as "txtfile" by default and thus open in the default text editor
|
||||
TCHAR *tLogFilePath = Win32::stringToTchar(_logFilePath);
|
||||
HINSTANCE shellExec = ShellExecute(getHwnd(), nullptr, tLogFilePath, nullptr, nullptr, SW_SHOWNORMAL);
|
||||
if ((intptr_t)shellExec > 32) {
|
||||
SHELLEXECUTEINFO sei;
|
||||
|
||||
memset(&sei, 0, sizeof(sei));
|
||||
sei.fMask = SEE_MASK_FLAG_NO_UI;
|
||||
sei.hwnd = getHwnd();
|
||||
sei.lpFile = tLogFilePath;
|
||||
sei.nShow = SW_SHOWNORMAL;
|
||||
|
||||
if (ShellExecuteEx(&sei)) {
|
||||
free(tLogFilePath);
|
||||
return true;
|
||||
}
|
||||
@ -196,11 +203,20 @@ bool OSystem_Win32::displayLogFile() {
|
||||
|
||||
bool OSystem_Win32::openUrl(const Common::String &url) {
|
||||
TCHAR *tUrl = Win32::stringToTchar(url);
|
||||
HINSTANCE result = ShellExecute(getHwnd(), nullptr, tUrl, nullptr, nullptr, SW_SHOWNORMAL);
|
||||
SHELLEXECUTEINFO sei;
|
||||
|
||||
memset(&sei, 0, sizeof(sei));
|
||||
sei.cbSize = sizeof(sei);
|
||||
sei.fMask = SEE_MASK_FLAG_NO_UI;
|
||||
sei.hwnd = getHwnd();
|
||||
sei.lpFile = tUrl;
|
||||
sei.nShow = SW_SHOWNORMAL;
|
||||
|
||||
BOOL success = ShellExecuteEx(&sei);
|
||||
|
||||
free(tUrl);
|
||||
// ShellExecute returns a value greater than 32 if successful
|
||||
if ((intptr_t)result <= 32) {
|
||||
warning("ShellExecute failed: error = %p", (void*)result);
|
||||
if (!success) {
|
||||
warning("ShellExecuteEx failed: error = %08lX", GetLastError());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user