[Scummvm-git-logs] scummvm master -> b195cbbcd0dd9839b4e15a39f3e78178ed684c23

lotharsm noreply at scummvm.org
Sat May 14 08:05:53 UTC 2022


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
b195cbbcd0 WIN32: Migrate from ShellExecute to ShellExecuteEx Function


Commit: b195cbbcd0dd9839b4e15a39f3e78178ed684c23
    https://github.com/scummvm/scummvm/commit/b195cbbcd0dd9839b4e15a39f3e78178ed684c23
Author: Carlo Bramini (30959007+carlo-bramini at users.noreply.github.com)
Date: 2022-05-14T10:05:50+02:00

Commit Message:
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().

Changed paths:
    backends/platform/sdl/win32/win32.cpp


diff --git a/backends/platform/sdl/win32/win32.cpp b/backends/platform/sdl/win32/win32.cpp
index fe3f6f4cc37..3df2d243c01 100644
--- a/backends/platform/sdl/win32/win32.cpp
+++ b/backends/platform/sdl/win32/win32.cpp
@@ -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;




More information about the Scummvm-git-logs mailing list