#include "emul_state.h"
#ifdef CONFIG_WIN32
-#include <process.h>
+#include <stdio.h>
+#include <windows.h>
#endif
#define MAX_MESSAGE_LEN 2048
char *app_path = get_app_path();
const char *title = "Emulator";
- const char *argv[] = {app_path, icon_types[icon], title, message, NULL};
#ifdef CONFIG_WIN32
- if (_spawnv(P_NOWAIT, app_path, (const char * const *) argv) == -1) {
- ERR("qt5_msgbox can not be executed. \n");
+ char *arg = g_strdup_printf("%s.exe %s %s %s", app_path, icon_types[icon], title, message);
+
+ PROCESS_INFORMATION process_info;
+ STARTUPINFO startup_info;
+ ZeroMemory(&startup_info, sizeof(startup_info));
+ startup_info.cb = sizeof startup_info;
+
+ if (!CreateProcess(NULL, // No module name (use command line)
+ arg, // Command line
+ NULL, // Process handle not inheritable
+ NULL, // Thread handle not inheritable
+ FALSE, // Set handle inheritance to FALSE
+ CREATE_NEW_PROCESS_GROUP, // Process Creation Flags
+ NULL, // Use parent's environment block
+ NULL, // USe parent's starting directory
+ &startup_info, // Pointer to STARTUPINFO structure
+ &process_info) // Pointer to PROCESS_INFORMATION structure
+ ) {
+ ERR("qt5_msgbox can not be executed. (%d) \n", GetLastError());
g_free(app_path);
+ g_free(arg);
return;
}
+
+ // Close process and thread handles
+ CloseHandle(process_info.hProcess);
+ CloseHandle(process_info.hThread);
+ g_free(arg);
#else
+ const char *argv[] = {app_path, icon_types[icon], title, message, NULL};
pid_t child_pid = fork();
if (child_pid == 0) {
if (execvp(app_path, (char * const *) argv) == -1) {