How to detect whether the OS supports 16-bit exes in Python? [duplicate]

StackOverflow https://stackoverflow.com/questions/9456171

  •  13-11-2019
  •  | 
  •  

Вопрос

This question already has an answer here:

This is essentially the same as asking how to detect that I am running under a 64-bit version of Windows.

os.name gives 'nt' under both win7 64 and winXP 32 (my two available test computers). sys.platform gives 'win32' in both of those cases.

It looks like the only thing I've found so far that works is to check the registry key HKLM\HARDWARE\DESCRIPTION\System\CentralProcessor\0\Identifier and if 'x86' doesn't appear in it, assume that means 64-bit windows. Is that reliable?

(the python process needs to run under python 2.7 32-bit)

Это было полезно?

Решение

Consider checking the PROCESSOR_ARCHITECTURE key in os.environ, and seeing if it's set to x86 or not.

Alternatively, you can use the platorm.architecture() call, but point it at a different executable from the Python one (since you're required to run under 32bit Python).

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top