0

I have python script that loads windows .dll file:

import ctypes
exDll = ctypes.CDLL('example.dll')

That dll library has code inside, that checks system version using MS interface. The windows version check (inside the dll, C++ code) looks like below:

if (IsWindows10OrGreater()){
  ... //some code
}

The problem is, that when I run the script on Windows Redstone 1 or 2, IsWindows10OrGreater() return false!
I've tried it with python 2.7.10 and 2.7.14. Both have the same problem.

I'm pretty sure that this is caused by python not being Windows 10 aware (it's described here: https://msdn.microsoft.com/pl-pl/library/windows/desktop/dn481241%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396).
I've took manifest file that contains GUIDs for all OSes (including Win 10) and then using mt.exe tool I've run it on my python.exe file. After that operation my dll loaded by python script was recognizing correctly Windows 10 system.
That solution is not nice because I need to modify python.exe and I need to do it on all client's machines.

So the question is:
is there some other, better and more scallable way to make windows 10 detection correct when dll is loaded by python?

zap
  • 133
  • 9
  • Why are you detecting version in the first place? If we can understand that, it will help us tell you the right way forward. – David Heffernan Oct 04 '17 at 10:03
  • [`GetProductInfo`](https://msdn.microsoft.com/en-us/library/windows/desktop/ms724358(v=vs.85).aspx) seems to not require editing the manifest. – bgfvdu3w Oct 04 '17 at 10:03
  • @DavidHeffernan The version is detected inside dll library and I can't modify it. This is single DLL for Win7, 8, 8.1, 10 etc. On windows 10 it has to do few things differently and it's not doing it because Windows 10 is not detected. – zap Oct 04 '17 at 10:07
  • @Mark, GetProductInfo is not used in the DLL. – zap Oct 04 '17 at 10:09
  • If you can't modify the DLL then I guess you need to use the activation context API – David Heffernan Oct 04 '17 at 10:17
  • @DavidHeffernan, can this be overridden with a new activation context? I tried, and it didn't work. I think it uses the process default activation context instead of the current context. – Eryk Sun Oct 14 '17 at 15:35

0 Answers0