// // Copyright (C) Microsoft Corporation. All rights reserved. // // dllmain.cpp : Defines the entry point for the DLL application. #include "pch.h" HINSTANCE g_hInst; STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, _COM_Outptr_ void** ppv) { try { *ppv = nullptr; if (rclsid == __uuidof(winrt::WindowsSample::implementation::SimpleMediaSourceActivate)) { return winrt::make_self()->QueryInterface(riid, ppv); } #ifdef _WRL_MODULE_H_ return ::Microsoft::WRL::Module<::Microsoft::WRL::InProc>::GetModule().GetClassObject(rclsid, riid, ppv); #else return winrt::hresult_class_not_available().to_abi(); #endif } catch (...) { return winrt::to_hresult(); } } bool __stdcall winrt_can_unload_now() noexcept { if (winrt::get_module_lock()) { return false; } winrt::clear_factory_cache(); return true; } int32_t __stdcall WINRT_CanUnloadNow() noexcept { #ifdef _WRL_MODULE_H_ if (!::Microsoft::WRL::Module<::Microsoft::WRL::InProc>::GetModule().Terminate()) { return 1; } #endif return winrt_can_unload_now() ? 0 : 1; } STDAPI_(BOOL) DllMain(_In_opt_ HINSTANCE hinst, DWORD reason, _In_opt_ void*) { switch (reason) { case DLL_PROCESS_ATTACH: case DLL_THREAD_ATTACH: case DLL_THREAD_DETACH: break; case DLL_PROCESS_DETACH: g_hInst = hinst; } return TRUE; }