pinvoke icon indicating copy to clipboard operation
pinvoke copied to clipboard

VerSetConditionMask fails on Win7

Open vatsan-madhavan opened this issue 3 years ago • 2 comments

VerSetConditionMask relies on the API set DLL api-ms-win-core-sysinfo-l1-2-0, which causes calls to it to fail on Windows 7.

https://github.com/dotnet/pinvoke/blob/2634eea66089c199790fcb72982936fd123bba24/src/Kernel32/Kernel32.cs#L728-L730

 ---> System.DllNotFoundException: Unable to load DLL 'api-ms-win-core-sysinfo-l1-2-0.dll' or one of its dependencies: 
        The specified module could not be found. (0x8007007E)
   at PInvoke.Kernel32.VerSetConditionMask(Int64 ConditionMask, VER_MASK TypeMask, VER_CONDITION Condition)

What's the policy on Win7 support? If our goal is to keep these libraries in general working condition on Win7, it would make sense to point VerSetConditionMask at Kernel32 directly instead of an APISet DLL.

vatsan-madhavan avatar Mar 16 '22 21:03 vatsan-madhavan

Have you tried using CsWin32 for this function? I think it would use kernel32.

AArnott avatar Mar 17 '22 00:03 AArnott

CsWin32 supports VerSetConditionMask, but I haven't given it a try. I'm frequently dealing with dual-mode API's (ones that are documented & available on both kernel and user mode) which CsWin32 doesn't support today (https://github.com/microsoft/win32metadata/issues/242).

In general, its simpler to rely on one system of P/Invokes [dotnet/pinvoke] over having a hybrid dependency on dotnet/pinvoke for some and CsWin32 for others (although I've found CsWin32 to be very helpful in a few other situations where I didn't expect to need dual-mode API's).

vatsan-madhavan avatar Mar 17 '22 19:03 vatsan-madhavan