示例#1
0
        private bool EnumMonitors(IntPtr hMonitor, IntPtr hdcMonitor, ref DisplayDDC.Rect lprcMonitor, IntPtr dwData)
        {
            int physicalMonitorCount = 0;
            DisplayDDC.GetNumberOfPhysicalMonitorsFromHMONITOR(hMonitor, out physicalMonitorCount);

            DisplayDDC.Physical_Monitor[] physicalMonitors;
            DisplayDDC.GetPhysicalMonitorsFromHMONITOR(hMonitor, out physicalMonitors);

            for(int i = 0; i < physicalMonitors.Length; ++i) {
                bool success = DisplayDDC.SetVCPFeature(physicalMonitors[i].hPhysicalMonitor, 0x60, 0x01);
            }

            IntPtr physicalMonitorsPtr = Marshal.AllocHGlobal(Marshal.SizeOf(physicalMonitors[0]) * physicalMonitors.Length);
            Marshal.StructureToPtr(physicalMonitors[0], physicalMonitorsPtr, false);
            DisplayDDC.DestroyPhysicalMonitors(physicalMonitors.Length, physicalMonitorsPtr);
            Marshal.FreeHGlobal(physicalMonitorsPtr);

            return true;
        }
示例#2
0
        private static bool EnumMonitorsInit(IntPtr hMonitor, IntPtr hdcMonitor, ref DisplayDDC.Rect lprcMonitor, IntPtr dwData)
        {
            uint physicalMonitorCount = 0;
            DisplayDDC.GetNumberOfPhysicalMonitorsFromHMONITOR(hMonitor, out physicalMonitorCount);

            DisplayDDC.Physical_Monitor[] physicalMonitors;
            bool success = DisplayDDC.GetPhysicalMonitorsFromHMONITOR(hMonitor, out physicalMonitors);
            if (success)
            {
                DisplayDDC.physicalMonitors.Add(physicalMonitors);
            }

            return true; // Return true to continue enumeration.
        }