The purpose of this is to determine which is the primary controller, and then it outputs the value of the Attach.ToDesktop key. I'm not certain this is the right registry key, and I don't have a system on which I can test multi-monitor at the moment. This is a partial solution, so I'm marking as community wiki answer. I believe it's the one called "Attach.ToDesktop". It looks like the setting lies under HKLM:\system\CurrentControlSet\control\video-somewhere. The next step would be to modify the registry directly. While you may be on to something with WMI, I searched for a while and wasn't able to find a satisfactory WMI class which is able to manipulate this setting. A lot of core OS stuff is unmanaged code which can only be manipulated via win32 API calls. This sort of operation is not directly accessible from PowerShell in the sense that there is not a. I have only tested this on a newly installed computer. Throw new NotSupportedException("Could not find a monitor with id " + id) If (!EnumDisplayDevices(null, (uint)id, ref d, 0)) Private static DISPLAY_DEVICE GetDisplayDevice(int id) Subkey.SetValue("DefaultSettings.BitsPerPel", 32, RegistryValueKind.DWord) Subkey.SetValue("DefaultSettings.YResolution", 768, RegistryValueKind.DWord) Subkey.SetValue("DefaultSettings.XResolution", 1024, RegistryValueKind.DWord) Subkey.SetValue("Attach.RelativeX", 1024, RegistryValueKind.DWord) Subkey.SetValue("Attach.ToDesktop", 1, RegistryValueKind.DWord) Using (var subkey = key.CreateSubKey("000" + secondaryIndex)) Var secondary = GetDisplayDevice(secondaryIndex) Public static void EnableSecondaryDisplay() / The device has more display modes than its output devices support. / The device is removable it cannot be the primary display. / Represents a pseudo device used to mirror application drawing for remoting or other purposes. Public DisplayDeviceStateFlags StateFlags Static extern bool EnumDisplayDevices(string lpDevice, uint iDevNum, ref DISPLAY_DEVICE lpDisplayDevice, uint dwFlags) Static extern DISP_CHANGE ChangeDisplaySettings(uint lpDevMode, uint dwflags) I've made a cleaner version that does not use sendkeys.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |