簡體   English   中英

使用 ctypes 調用 windows api function 設置顏色配置文件

[英]use ctypes call windows api function to set color profile

我正在嘗試使用 ctypes 調用 windows api function 來設置顏色配置文件。 根據文檔,我必須先安裝顏色配置文件,然后將其關聯到顯示器。 就我而言,我想關聯到顯示器 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,0)
associateProfile = mscms.AssociateColorProfileWithDeviceW(None,profile_path,Device.DeviceName)
print('associateProfile: ',associateProfile)

也許可能會有所幫助,以下是可用於管理顏色配置文件的功能列表。

具體來說, InstallProfileColorW可能是您正在尋找的。

我認為pywin32目前不支持這一點,並且需要您自己使用ctypescffi來創建特定的綁定,或者可能編寫一個 Python 擴展來為您執行此操作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM