mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-12 10:22:12 +02:00
Common (Windows): uses WinRT APIs only when FF_HAVE_WINRT is defined
This commit is contained in:
+3
-4
@@ -1340,9 +1340,9 @@ if(WIN32)
|
||||
include(CheckIncludeFileCXX)
|
||||
CHECK_INCLUDE_FILE_CXX("winrt/Windows.Foundation.h" HAVE_WINRT)
|
||||
if(HAVE_WINRT)
|
||||
message(STATUS "WinRT headers are available, media detection will use WinRT APIs")
|
||||
message(STATUS "WinRT headers are available, media detection will be enabled")
|
||||
else()
|
||||
message(STATUS "WinRT headers are NOT available, media detection will be disabled")
|
||||
message(WARNING "WinRT headers are NOT available, media detection will be disabled")
|
||||
endif()
|
||||
endif()
|
||||
include(CheckFunctionExists)
|
||||
@@ -1759,8 +1759,7 @@ elseif(WIN32)
|
||||
endif()
|
||||
if(HAVE_WINRT)
|
||||
target_link_libraries(libfastfetch
|
||||
PRIVATE
|
||||
"RuntimeObject"
|
||||
PRIVATE "runtimeobject"
|
||||
)
|
||||
endif()
|
||||
elseif(FreeBSD)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "com.h"
|
||||
|
||||
#include <roapi.h>
|
||||
#if FF_HAVE_WINRT
|
||||
#include <roapi.h>
|
||||
|
||||
static void RoUninitializeWrap(void) {
|
||||
RoUninitialize();
|
||||
@@ -27,6 +28,33 @@ static const char* doInitCom() {
|
||||
atexit(RoUninitializeWrap);
|
||||
return NULL;
|
||||
}
|
||||
#else
|
||||
#include <combaseapi.h>
|
||||
|
||||
static void CoUninitializeWrap(void) {
|
||||
CoUninitialize();
|
||||
}
|
||||
|
||||
static const char* doInitCom() {
|
||||
HRESULT res = CoInitializeEx(NULL, COINIT_MULTITHREADED);
|
||||
if (FAILED(res)) {
|
||||
switch (res) {
|
||||
case E_INVALIDARG:
|
||||
return "CoInitializeEx() failed: invalid argument";
|
||||
case E_OUTOFMEMORY:
|
||||
return "CoInitializeEx() failed: out of memory";
|
||||
case RPC_E_CHANGED_MODE:
|
||||
// COM was already initialized with a different concurrency model
|
||||
return NULL;
|
||||
default:
|
||||
return "CoInitializeEx() failed: unknown error";
|
||||
}
|
||||
}
|
||||
|
||||
atexit(CoUninitializeWrap);
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
const char* ffInitCom(void) {
|
||||
static const char* error = "";
|
||||
|
||||
Reference in New Issue
Block a user