Whereas many Windows API functions exist in Windowsapp.lib or in API sets (see this answer to How to declare and link to RoInitialize,RoUninitialize,RoGetActivationFactory and HSTRING Functions in Mingw Gcc), many functions are not listed as included in WindowsApp.lib or in the extension APIs.
For example, timeBeginPeriod, which I want to use to set the resolution for Sleep.
It is part of Timeapi, which is not mentioned anywhere in the list of functions available in WindowsApp.lib or extension APIs. The documentation also does not mention any API set.
- Do I link to
winmm.libandwinmm.dll? - Do I include
Windows.hortimeapi.h?
How would I know? RoInitialize does not mention a DLL or an API set, but it is available in several.
Disclaimer: I work for Microsoft.
I figured I'd look into this myself. I wrote a little test program and used the VS compiler to test.
The answer
My experimentation showed that the answer to this question is not necessarily straightforward:
You may link/consume
winmm, butwindowsapp.libis also sufficient, even though it is not documented that the time API functions are part of it.At least in my experimentation,
Windows.hwas actually required to usetimeBeginPeriod.timeapi.hwas not sufficient or necessary. It is unclear to me why that is the case.Here's how I got this answer:
Compiling a simple program
Just to prove things will compile:
Consume functions known to exist in Windowsapp.lib
Consuming functions time API functions (this question)
Linking winmm.lib:
Interestingly, you can also link just Windowsapp.lib instead: