private static bool SetMonitorHdrStatus(LUID adapterId, uint targetId, bool hdrEnabled) { try { DISPLAYCONFIG_SET_ADVANCED_COLOR_STATE deviceInfo = new DISPLAYCONFIG_SET_ADVANCED_COLOR_STATE(); deviceInfo.header.size = (uint)Marshal.SizeOf(typeof(DISPLAYCONFIG_SET_ADVANCED_COLOR_STATE)); deviceInfo.header.adapterId = adapterId; deviceInfo.header.id = targetId; deviceInfo.header.type = DISPLAYCONFIG_DEVICE_INFO_TYPE.DISPLAYCONFIG_DEVICE_INFO_SET_ADVANCED_COLOR_STATE; deviceInfo.advancedColorEnabled = hdrEnabled; int error = DisplayConfigSetDeviceInfo(ref deviceInfo); if (error != 0) { Debug.WriteLine("Failed SetMonitorHdrStatus: " + error); return(false); } return(true); } catch { Debug.WriteLine("Failed SetMonitorHdrStatus."); return(false); } }
private static extern int DisplayConfigSetDeviceInfo(ref DISPLAYCONFIG_SET_ADVANCED_COLOR_STATE requestPacket);