SDL  2.0
SDL_sysurl.c File Reference
#include "../SDL_sysurl.h"
#include "../../core/windows/SDL_windows.h"
#include <shellapi.h>
+ Include dependency graph for SDL_sysurl.c:

Go to the source code of this file.

Functions

int SDL_SYS_OpenURL (const char *url)
 

Function Documentation

◆ SDL_SYS_OpenURL()

int SDL_SYS_OpenURL ( const char *  url)

Definition at line 29 of file SDL_sysurl.c.

30 {
31  WCHAR* wurl;
32  HINSTANCE rc;
33 
34  /* MSDN says for safety's sake, make sure COM is initialized. */
35  const HRESULT hr = WIN_CoInitialize();
36  if (FAILED(hr)) {
37  return WIN_SetErrorFromHRESULT("CoInitialize failed", hr);
38  }
39 
40  wurl = WIN_UTF8ToString(url);
41  if (wurl == NULL) {
43  return SDL_OutOfMemory();
44  }
45 
46  /* Success returns value greater than 32. Less is an error. */
47  rc = ShellExecuteW(NULL, L"open", wurl, NULL, NULL, SW_SHOWNORMAL);
48  SDL_free(wurl);
50  return (rc > ((HINSTANCE) 32)) ? 0 : WIN_SetError("Couldn't open given URL.");
51 }
#define FAILED(x)
Definition: SDL_directx.h:54
#define SDL_free
#define SDL_OutOfMemory()
Definition: SDL_error.h:88
HRESULT WIN_CoInitialize(void)
#define WIN_UTF8ToString(S)
Definition: SDL_windows.h:47
void WIN_CoUninitialize(void)
int WIN_SetError(const char *prefix)
int WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr)
#define NULL
Definition: begin_code.h:163
struct HINSTANCE__ * HINSTANCE
Definition: vulkan.hpp:72

References FAILED, NULL, SDL_free, SDL_OutOfMemory, WIN_CoInitialize(), WIN_CoUninitialize(), WIN_SetError(), WIN_SetErrorFromHRESULT(), and WIN_UTF8ToString.