I have a C++ app built inside OpenKODE environment. Specifically for WinRT platform I need a function, which can tell me if mouse is connected to the machine. I am trying to solve this using Windows Runtime C++ Template Library (WRL) and accessing the MouseCapabilities.MousePresent property. So my code is following (it compiles only for WinRT):
#include <Windows.Foundation.h>
#include <Windows.Devices.Input.h>
#include <wrl\wrappers\corewrappers.h>
#include <wrl\client.h>
...
// Initialize the Windows Runtime.
RoInitializeWrapper initialize(RO_INIT_MULTITHREADED);
if (FAILED(initialize))
{
return PrintError(__LINE__, initialize);
}
ComPtr<IMouseCapabilities> mouseCapabilities;
HRESULT hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_Devices_Input_MouseCapabilities).Get(), &mouseCapabilities);
if (FAILED(hr))
{
return PrintError(__LINE__, hr);
}
INT32 present = 0;
hr = mouseCapabilities->get_MousePresent(&present);
if (FAILED(hr))
{
return PrintError(__LINE__, hr);
}
But my GetActivationFactory returns failed HRESULT with 0x80004002 (E_NOINTERFACE) code. I am new to WRL or other COM-like libraries, please help me what I did wrong?