WcsGetDefaultColorProfile的代码示例 [英] Code example for WcsGetDefaultColorProfile

查看:278
本文介绍了WcsGetDefaultColorProfile的代码示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有人有工作代码示例显示对Windows颜色系统功能 WcsGetDefaultColorProfile 的调用,以获取特定设备的默认颜色配置文件?当我为pDeviceName参数传递null时,它对我有用,但是当我尝试传递监视器的设备名称时,我总是返回错误代码ERROR_FILE_NOT_FOUND.

Does anyone have a working code example showing a call to the Windows Color System function WcsGetDefaultColorProfile to get the default color profile for a specific device? It works for me when I pass null for the pDeviceName parameter, but when I try to pass the device name of a monitor, I always get back an error code of ERROR_FILE_NOT_FOUND.

我希望有一个C#示例,但是我将尽我所能.我找不到任何新的WCS配置文件管理功能的示例代码.

I would prefer a C# example, but I'll take anything I can get. I can't find any sample code for the newer WCS profile management functions anywhere.

推荐答案

我遇到了同样的问题,而让您感到沮丧的原因是MSDN文档关于WcsGetDefaultColorProfile的pDeviceName参数是错误的(或至少会引起误解)

I was running into the same problem, and the reason for your frustration is that the MSDN docs are incorrect (or at best misleading) about the pDeviceName parameter to WcsGetDefaultColorProfile.

MSDN文档( http://msdn .microsoft.com/en-us/library/dd372247(v = vs.85).aspx )表示pDeviceName指的是设备名称",对于显示设备,它会假定是Windows显示器设备名称,例如从EnumDisplayDevices在DISPLAY_DEVICE结构的DeviceName参数中返回的"\.\ DISPLAY1".

The MSDN doc (http://msdn.microsoft.com/en-us/library/dd372247(v=vs.85).aspx) indicates pDeviceName refers to the "name of the device", which for display devices one would assume to be a windows display device name, such as "\.\DISPLAY1", as returned in the DeviceName parameter of the DISPLAY_DEVICE struct from EnumDisplayDevices.

实际上,这里需要的是监视器的DeviceKey参数,尤其是在EnumDisplayDevices中使用EDD_GET_DEVICE_INTERFACE_NAME标志时获得的DeviceKey.

In fact, what it is requiring here is the DeviceKey parameter of the monitor, and specifically the DeviceKey obtained when the EDD_GET_DEVICE_INTERFACE_NAME flag is used in EnumDisplayDevices.

因此,假设szDisplayDeviceName已设置为显示您关心的设备名称,则工作代码如下所示:

So working code looks like this, assuming szDisplayDeviceName is already set to display device name you care about, e.g., "\.\DISPLAY1":

WCHAR szPath[MAX_PATH];
DISPLAY_DEVICE dd;
dd.cb = sizeof(dd);
if (EnumDisplayDevices(szDisplayDeviceName, 0, &dd, EDD_GET_DEVICE_INTERFACE_NAME))
{
    if (WcsGetDefaultColorProfile(WCS_PROFILE_MANAGEMENT_SCOPE_CURRENT_USER, 
          dd.DeviceKey,
          CPT_ICC,
          CPST_PERCEPTUAL,
          1,  // dwProfileID -- doesn't seem to matter what value you use here
          MAX_PATH * sizeof(WCHAR),
          szPath))
    {
        PROFILE profile;
        profile.cbDataSize = (DWORD)(wcslen(szPath) + 1) * sizeof(WCHAR);
        profile.dwType = PROFILE_FILENAME;
        profile.pProfileData = (PVOID)szPath;

        HPROFILE hProfile = OpenColorProfile(&profile,
           PROFILE_READ, FILE_SHARE_READ, OPEN_EXISTING);

        // now do something with the profile
    }
}

这篇关于WcsGetDefaultColorProfile的代码示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆