/// <summary> /// This method give you access to monitor device name. /// Such as "\\DISPLAY1" /// </summary> /// <param name="sourceModeInfo"></param> /// <param name="displayConfigSourceDeviceName"></param> /// <returns></returns> private static StatusCode GetDisplayConfigSourceDeviceName( DisplayConfigModeInfo sourceModeInfo, out DisplayConfigSourceDeviceName displayConfigSourceDeviceName) { displayConfigSourceDeviceName = new DisplayConfigSourceDeviceName { header = new DisplayConfigDeviceInfoHeader { adapterId = sourceModeInfo.adapterId, id = sourceModeInfo.id, size = Marshal.SizeOf( typeof(DisplayConfigSourceDeviceName)), type = DisplayConfigDeviceInfoType.GetSourceName, } }; return(CCDWrapper.DisplayConfigGetDeviceInfo(ref displayConfigSourceDeviceName)); }
/// <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); }