mirror of https://github.com/encounter/SDL.git
url: More win32 fixes.
This commit is contained in:
parent
3fe5ce7b9a
commit
0099e38a9a
|
@ -23,20 +23,30 @@
|
||||||
#include "../../core/windows/SDL_windows.h"
|
#include "../../core/windows/SDL_windows.h"
|
||||||
#include "SDL_error.h"
|
#include "SDL_error.h"
|
||||||
|
|
||||||
|
#include <shellapi.h>
|
||||||
|
|
||||||
/* https://msdn.microsoft.com/en-us/library/windows/desktop/bb762153%28v=vs.85%29.aspx */
|
/* https://msdn.microsoft.com/en-us/library/windows/desktop/bb762153%28v=vs.85%29.aspx */
|
||||||
int
|
int
|
||||||
SDL_SYS_OpenURL(const char *url)
|
SDL_SYS_OpenURL(const char *url)
|
||||||
{
|
{
|
||||||
|
/* MSDN says for safety's sake, make sure COM is initialized. */
|
||||||
|
const HRESULT hr = WIN_CoInitialize();
|
||||||
|
if (FAILED(hr)) {
|
||||||
|
return WIN_SetErrorFromHRESULT("CoInitialize failed", hr);
|
||||||
|
}
|
||||||
|
|
||||||
WCHAR* wurl = WIN_UTF8ToString(url);
|
WCHAR* wurl = WIN_UTF8ToString(url);
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
if (wurl == NULL) {
|
if (wurl == NULL) {
|
||||||
|
WIN_CoUninitialize();
|
||||||
return SDL_OutOfMemory();
|
return SDL_OutOfMemory();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Success returns value greater than 32. Less is an error. */
|
/* Success returns value greater than 32. Less is an error. */
|
||||||
rc = (int) ShellExecuteW(NULL, L"open", wurl, NULL, NULL, SW_SHOWNORMAL);
|
rc = (int) ShellExecuteW(NULL, L"open", wurl, NULL, NULL, SW_SHOWNORMAL);
|
||||||
SDL_free(wurl);
|
SDL_free(wurl);
|
||||||
|
WIN_CoUninitialize();
|
||||||
return (rc > 32) ? 0 : WIN_SetError("Couldn't open given URL.");
|
return (rc > 32) ? 0 : WIN_SetError("Couldn't open given URL.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue