使用 ctypes 调用 windows api 函数来设置颜色配置文件

问题描述

我正在尝试使用 ctypes 调用 windows api 函数来设置颜色配置文件。根据文档,我必须先安装颜色配置文件,然后将其关联到显示器。就我而言,我想关联到显示 1. mscms.AssociateColorProfileWithDeviceW(None,profile_path,Device.DeviceName) 返回 0。我检查了颜色管理。配置文件没有关联。有人知道这里有什么问题吗?谢谢!

代码如下:

import ctypes
from ctypes import wintypes
import win32api as w
import win32con as c 
mscms = ctypes.CDLL("Mscms.dll")
profile_path = r'C:\Windows\System32\spool\drivers\color\test.icm'
#install profile
res = mscms.InstallColorProfileW(None,profile_path)
Device = w.EnumdisplayDevices(None,0)
associateProfile = mscms.AssociateColorProfileWithDeviceW(None,Device.DeviceName)
print('associateProfile: ',associateProfile)

解决方法

也许 this 可能会有所帮助,以下是您可以用来管理颜色配置文件的功能列表。

具体来说,InstallProfileColorW 可能正是您要找的。​​p>

我认为 pywin32 目前不支持此功能,需要您自己使用 ctypescffi 来创建特定绑定,或者编写一个 Python 扩展为你做这个。

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...