How to access the GetDoubleClickTime Win32 API function from a WinUI 3.0 Runtime Component library
I'm trying to call the GetDoubleClickTime Win32 API function using C++ from a new project created with the "Windows Runtime Component (WinUI 3)" Visual Studio template.
To do so, I'm adding #include <Windows.h>
to the pch.h
file and then simply call the mentioned function. However, I'm getting the following compiler error afterwards: error C3861: 'GetDoubleClickTime': identifier not found
.
According to the template description, this project should create a library that is both usable in Desktop and UWP apps. I'm aware that the GetDoubleClickTime
function cannot be called from UWP. But it has to work for Desktop apps.
How can I make this work?
Apparently it creates a sandboxed UWP project behind the scenes. Please refer to this GitHub issue and see @sylveon's comments at the very bottom of the conversation for a potential fix/workaorund.
You can edit the vcxproj's global PropertyGroup and add these two directives right now to force the UWP project to use the desktop API set, and link the desktop CRT (removing the need to carry around the VCRT forwarders, which are honestly a terrible hack)
<_NoWinAPIFamilyApp>true</_NoWinAPIFamilyApp>
<_VC_Target_Library_Platform>Desktop</_VC_Target_Library_Platform>
Alternatively, it seems that merely setting
<AppContainerApplication>false</AppContainerApplication>
works as well.