在Python中检测图形驱动程序信息

时间:2015-02-25 16:28:56

标签: python windows

我有一个应用程序需要安装最低版本的NVIDIA图形驱动程序才能工作。如何在Windows上获取通过Python安装的驱动程序版本?

编辑:

通过注册表执行此操作的方法,它可以安装所有版本(由Yojimbo提供)

cmd = r'reg query "HKEY_LOCAL_MACHINE\SOFTWARE\NVIDIA Corporation\Installer2\Stripped" /s | find "Display.Driver/"'
output = subprocess.check_output(cmd, shell=True)
all = [float(x) for x in re.findall('Display\.Driver/(\d+\.?\d*)', str(output))]
latest = max(all)

2 个答案:

答案 0 :(得分:1)

您可以使用需要PyWin32的wmi模块。这样的事情,也许是:

import wmi

c = wmi.WMI()

video =  c.Win32_videocontroller
print video.properties

我目前没有真正的Windows机箱,我的Windows VM返回了一堆Nones,但我认为这应该可行。

答案 1 :(得分:0)

上面提到的WMI方法将为您提供文件版本,而不是您期望的实际驱动程序版本。您需要安装NVidia WMI并连接到root / CIMV @ / NV命名空间,您可以在其中找到带有verDisplayDriver属性的System对象,该属性提供驱动程序版本。

nvidia = wmi.WMI(computer, user=r"usern", password="pass", namespace="/root/cimv2/NV", find_classes=True)
for o in nvidia.System() :
    print o.verDisplayDriver.strValue