src/core/windows/SDL_windows.c
changeset 5591 17beb16fa838
parent 5535 96594ac5fd1a
child 5598 4d05ee9088b1
equal deleted inserted replaced
5590:db152c9f31c3 5591:17beb16fa838
    21 #include "SDL_config.h"
    21 #include "SDL_config.h"
    22 
    22 
    23 #include "SDL_error.h"
    23 #include "SDL_error.h"
    24 #include "SDL_windows.h"
    24 #include "SDL_windows.h"
    25 
    25 
       
    26 #include <objbase.h>  /* for CoInitialize/CoUninitialize */
       
    27 
    26 
    28 
    27 /* Sets an error message based on GetLastError() */
    29 /* Sets an error message based on GetLastError() */
    28 void
    30 void
    29 WIN_SetError(const char *prefix)
    31 WIN_SetError(const char *prefix)
    30 {
    32 {
    35     message = WIN_StringToUTF8(buffer);
    37     message = WIN_StringToUTF8(buffer);
    36     SDL_SetError("%s%s%s", prefix ? prefix : "", prefix ? ": " : "", message);
    38     SDL_SetError("%s%s%s", prefix ? prefix : "", prefix ? ": " : "", message);
    37     SDL_free(message);
    39     SDL_free(message);
    38 }
    40 }
    39 
    41 
       
    42 HRESULT
       
    43 WIN_CoInitialize(void)
       
    44 {
       
    45     /* S_FALSE means success, but someone else already initialized. */
       
    46     /* You still need to call CoUninitialize in this case! */
       
    47     const HRESULT hr = CoInitialize(NULL);
       
    48     if ((hr == S_OK) || (hr == S_FALSE)) {
       
    49         return S_OK;
       
    50     }
       
    51 
       
    52     return hr;
       
    53 }
       
    54 
       
    55 void
       
    56 WIN_CoUninitialize(void)
       
    57 {
       
    58     CoUninitialize();
       
    59 }
       
    60 
    40 /* vi: set ts=4 sw=4 expandtab: */
    61 /* vi: set ts=4 sw=4 expandtab: */