Beispiel #1
0
        public static void SwapMonitor(int _1, int _2)
        {
            DisplayApi.DisplaySetting_Results displaySetting_Results = DisplayApi.DisplaySetting_Results.DISP_CHANGE_SUCCESSFUL;
            DisplayApi.DISPLAY_DEVICE         lpDisplayDevice        = default(DisplayApi.DISPLAY_DEVICE);
            lpDisplayDevice.cb = Marshal.SizeOf((object)lpDisplayDevice);
            int iDevNum = _2;

            DisplayApi.User_32.EnumDisplayDevices(null, iDevNum, ref lpDisplayDevice, 0);
            string deviceName = lpDisplayDevice.DeviceName;

            DisplayApi.DISPLAY_DEVICE lpDisplayDevice2 = default(DisplayApi.DISPLAY_DEVICE);
            lpDisplayDevice2.cb = Marshal.SizeOf((object)lpDisplayDevice2);
            iDevNum             = _1;
            DisplayApi.User_32.EnumDisplayDevices(null, iDevNum, ref lpDisplayDevice2, 0);
            string deviceName2 = lpDisplayDevice2.DeviceName;

            DisplayApi.DEVMODE devMode = NewDevMode();
            DisplayApi.User_32.EnumDisplaySettings(deviceName, -2, ref devMode);
            DisplayApi.DEVMODE lpDevMode = NewDevMode();
            lpDevMode.dmFields     = DisplayApi.DEVMODE_Flags.DM_POSITION;
            lpDevMode.dmPosition.x = (int)devMode.dmPelsWidth;
            lpDevMode.dmPosition.y = 0;
            displaySetting_Results = (DisplayApi.DisplaySetting_Results)DisplayApi.User_32.ChangeDisplaySettingsEx(deviceName2, ref lpDevMode, (IntPtr)null, 268435457, IntPtr.Zero);
            DisplayApi.DEVMODE devMode2 = NewDevMode();
            DisplayApi.User_32.EnumDisplaySettings(deviceName, -2, ref devMode2);
            DisplayApi.DEVMODE lpDevMode2 = NewDevMode();
            lpDevMode2.dmFields     = DisplayApi.DEVMODE_Flags.DM_POSITION;
            lpDevMode2.dmPosition.x = 0;
            lpDevMode2.dmPosition.y = 0;
            displaySetting_Results  = (DisplayApi.DisplaySetting_Results)DisplayApi.User_32.ChangeDisplaySettingsEx(deviceName, ref lpDevMode2, (IntPtr)null, 268435473, IntPtr.Zero);
            DisplayApi.DEVMODE lpDevMode3 = NewDevMode();
            displaySetting_Results = (DisplayApi.DisplaySetting_Results)DisplayApi.User_32.ChangeDisplaySettingsEx(deviceName2, ref lpDevMode3, (IntPtr)null, 1, (IntPtr)null);
            DisplayApi.DEVMODE lpDevMode4 = NewDevMode();
            displaySetting_Results = (DisplayApi.DisplaySetting_Results)DisplayApi.User_32.ChangeDisplaySettingsEx(deviceName, ref lpDevMode4, (IntPtr)null, 17, IntPtr.Zero);
        }
Beispiel #2
0
 public static DisplayApi.DEVMODE NewDevMode()
 {
     DisplayApi.DEVMODE dEVMODE = default(DisplayApi.DEVMODE);
     dEVMODE.dmDeviceName = new string(new char[31]);
     dEVMODE.dmFormName   = new string(new char[31]);
     dEVMODE.dmSize       = (ushort)Marshal.SizeOf((object)dEVMODE);
     return(dEVMODE);
 }