From 4d4cec9593ff84d30a41e0802bd5c64e5d3a65c8 Mon Sep 17 00:00:00 2001 From: es3n1n Date: Fri, 30 May 2025 11:01:45 +0200 Subject: [PATCH] feat(com): display detailed error message if WSC not available --- defendnot/core/com.hpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/defendnot/core/com.hpp b/defendnot/core/com.hpp index 3baee4f..b60909c 100644 --- a/defendnot/core/com.hpp +++ b/defendnot/core/com.hpp @@ -92,7 +92,14 @@ namespace defendnot { public: static IWscAVStatus* get() { IWscAVStatus* result = nullptr; - com_checked(CoCreateInstance(detail::CLSID_IWscAVStatus, 0, 1, detail::IID_IWscAVStatus, reinterpret_cast(&result))); + const auto status = CoCreateInstance(detail::CLSID_IWscAVStatus, 0, 1, detail::IID_IWscAVStatus, reinterpret_cast(&result)); + if (status == REGDB_E_CLASSNOTREG) { + throw std::runtime_error("Windows Security Center (WSC) is not available on this machine.\n" + "This typically occurs on Windows Server operating systems, which are not supported by this tool.\n" + "For more details, please refer to: https://github.com/es3n1n/defendnot/issues/17"); + } + + com_checked(status); return result; } };