private static StatusCode GetDisplayConfigTargetDeviceName( DisplayConfigModeInfo targetModeInfo, out DisplayConfigTargetDeviceName displayConfigTargetDeviceName) { displayConfigTargetDeviceName = new DisplayConfigTargetDeviceName { header = new DisplayConfigDeviceInfoHeader { adapterId = targetModeInfo.adapterId, id = targetModeInfo.id, size = Marshal.SizeOf( typeof(DisplayConfigTargetDeviceName)), type = DisplayConfigDeviceInfoType.GetTargetName, } }; return CCDWrapper.DisplayConfigGetDeviceInfo(ref displayConfigTargetDeviceName); }
/// <summary> /// This method can be used in order to filter out specific paths that we are interested, /// a long with their corresponding paths. /// </summary> /// <param name="pathType"></param> /// <param name="topologyId"></param> /// <returns></returns> private static IEnumerable<DisplayConfigPathWrap> GetPathWrap(QueryDisplayFlags pathType, out DisplayConfigTopologyId topologyId) { topologyId = DisplayConfigTopologyId.Zero; int numPathArrayElements; int numModeInfoArrayElements; var status = CCDWrapper.GetDisplayConfigBufferSizes( pathType, out numPathArrayElements, out numModeInfoArrayElements); if (status != StatusCode.Success) { // TODO; POSSIBLY HANDLE SOME OF THE CASES. var reason = string.Format("GetDisplayConfigBufferSizesFailed() failed. Status: {0}", status); throw new Exception(reason); } var pathInfoArray = new DisplayConfigPathInfo[numPathArrayElements]; var modeInfoArray = new DisplayConfigModeInfo[numModeInfoArrayElements]; // topology ID only valid with QDC_DATABASE_CURRENT var queryDisplayStatus = pathType == QueryDisplayFlags.DatabaseCurrent ? CCDWrapper.QueryDisplayConfig( pathType, ref numPathArrayElements, pathInfoArray, ref numModeInfoArrayElements, modeInfoArray, out topologyId) : CCDWrapper.QueryDisplayConfig( pathType, ref numPathArrayElements, pathInfoArray, ref numModeInfoArrayElements, modeInfoArray); ////////////////////// if (queryDisplayStatus != StatusCode.Success) { // TODO; POSSIBLY HANDLE SOME OF THE CASES. var reason = string.Format("QueryDisplayConfig() failed. Status: {0}", queryDisplayStatus); throw new Exception(reason); } var list = new List<DisplayConfigPathWrap>(); foreach (var path in pathInfoArray) { var outputModes = new List<DisplayConfigModeInfo>(); foreach (var modeIndex in new[] { path.sourceInfo.modeInfoIdx, path.targetInfo.modeInfoIdx }) { if (modeIndex >= 0 && modeIndex < modeInfoArray.Length) outputModes.Add(modeInfoArray[modeIndex]); } list.Add(new DisplayConfigPathWrap(path, outputModes)); } return list; }