Having an unusual problem running Win32C++ source codes with the function DCompositionCreateDevice2
, which is compiled with VS 2015.
The source codes compile without any error but display the above runtime error. Recompiling and running the same source codes with VS 2019, there is no runtime error.
The test sample codes are Windows SDK samples listed below:
TouchInputDirectManipulation
Any idea what could be the source of this problem? I am working on WTL open source project, and do not want to restrict the build environment to VS 2019.
This is actually an unusual issue... What happens is Microsoft has seriously messed up
dcomp.lib
between the Windows 8.1 SDK and the Windows 10 SDK.Here is what you see if you dump the Windows 8.1 SDK dcomp.lib exports:
And here is what you see if you dump the Windows 10 SDK dcomp.lib exports:
As you can see the
DCompositionCreateDevice2
was defined with ordinal 1017 initially. When you build your program using the Windows 8.1 SDK (which is how theses samples are currently defined), you get that using dumpbin:So, your .exe is linked to ordinal 1017, not to exported name
DCompositionCreateDevice2
.The problem is, with Windows 10 (I think you're running on Windows 10), dcomp ordinal 1017 is not
DCompositionCreateDevice2
butDCompositionAttachMouseDragToHwnd
! This can be confirmed if you debug your program, you land into that function that doesn't like what you send to it and reports E_INVALIDARG.So the solution is to change the SDK if you target Windows 10:
Or simply use
GetProcAddress("DCompositionCreateDevice2")
etc. to dcomp.dll to make sure you get the good one.This should be reported to Microsoft I guess...