diff options
author | Simon Howard | 2015-06-07 19:15:12 -0400 |
---|---|---|
committer | Simon Howard | 2015-06-07 19:15:12 -0400 |
commit | f69c5a10071b9ac231fd2edfeb49fa6afd7c3948 (patch) | |
tree | 1ab6d856b542fc1ea3f69ecc50549c5e62d9e710 | |
parent | f30f390e513e456c2bdec64726469a50097e4371 (diff) | |
parent | b44b84beb3d7c3cf7e56bf1796d49102c5f9e562 (diff) | |
download | chocolate-doom-f69c5a10071b9ac231fd2edfeb49fa6afd7c3948.tar.gz chocolate-doom-f69c5a10071b9ac231fd2edfeb49fa6afd7c3948.tar.bz2 chocolate-doom-f69c5a10071b9ac231fd2edfeb49fa6afd7c3948.zip |
Merge pull request #548 from chungy/shellexecute
textscreen: use ShellExecute on Windows to open URLs
-rw-r--r-- | textscreen/txt_window.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/textscreen/txt_window.c b/textscreen/txt_window.c index 5aa35edf..41b8c8ef 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) @@ -515,11 +521,9 @@ void TXT_OpenURL(char *url) cmd_len = strlen(url) + 30; cmd = malloc(cmd_len); -#if defined(_WIN32) - TXT_snprintf(cmd, cmd_len, "cmd /c start \"%s\"", url); -#elif defined(__MACOSX__) +#if defined(__MACOSX__) TXT_snprintf(cmd, cmd_len, "open \"%s\"", url); -#else +#elif !defined(_WIN32) // The Unix situation sucks as usual, but the closest thing to a // standard that exists is the xdg-utils package. if (system("xdg-open --version 2>/dev/null") != 0) @@ -532,7 +536,11 @@ void TXT_OpenURL(char *url) TXT_snprintf(cmd, cmd_len, "xdg-open \"%s\"", url); #endif +#if defined(_WIN32) + ShellExecute(NULL, "open", url, NULL, NULL, SW_SHOWNORMAL); +#else system(cmd); +#endif free(cmd); } |