summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Swanson2015-06-05 22:49:27 -0700
committerMike Swanson2015-06-05 22:49:27 -0700
commit7265f8d9b9bd15a05f51f30392928fd2f869b0cd (patch)
tree11b3554007a603b7c7fedf212173eee87831f7a7
parentf30f390e513e456c2bdec64726469a50097e4371 (diff)
downloadchocolate-doom-7265f8d9b9bd15a05f51f30392928fd2f869b0cd.tar.gz
chocolate-doom-7265f8d9b9bd15a05f51f30392928fd2f869b0cd.tar.bz2
chocolate-doom-7265f8d9b9bd15a05f51f30392928fd2f869b0cd.zip
textscreen: use ShellExecute on Windows to open URLs
Trying to use the cmd.exe built-in has been causing nothing but troubles, this is the officially supported way to open them.
-rw-r--r--textscreen/txt_window.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/textscreen/txt_window.c b/textscreen/txt_window.c
index 5aa35edf..44cdf9d1 100644
--- a/textscreen/txt_window.c
+++ b/textscreen/txt_window.c
@@ -27,6 +27,12 @@
#include "txt_separator.h"
#include "txt_window.h"
+#ifdef _WIN32
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#include <shellapi.h>
+#endif
+
void TXT_SetWindowAction(txt_window_t *window,
txt_horiz_align_t position,
txt_window_action_t *action)
@@ -516,7 +522,7 @@ void TXT_OpenURL(char *url)
cmd = malloc(cmd_len);
#if defined(_WIN32)
- TXT_snprintf(cmd, cmd_len, "cmd /c start \"%s\"", url);
+ TXT_snprintf(cmd, cmd_len, "%s", url);
#elif defined(__MACOSX__)
TXT_snprintf(cmd, cmd_len, "open \"%s\"", url);
#else
@@ -532,7 +538,11 @@ void TXT_OpenURL(char *url)
TXT_snprintf(cmd, cmd_len, "xdg-open \"%s\"", url);
#endif
+#if defined(_WIN32)
+ ShellExecute(NULL, "open", cmd, NULL, NULL, SW_SHOWNORMAL);
+#else
system(cmd);
+#endif
free(cmd);
}