I´m writing a Windows 10 application using C++/CLI. The application is going to run on a portable computer (that runs standard Win10 SO, not the tablet version).
This portable computer has autorotation, but I need to keep my application only in Portrait configuration.
I want to disable screen autorotation when the application comes up. Is there a C++/CLI command, a C# command or a batch command that I can do it programatically (the batch would be called from my app) ?
Use regini.exe
, with a parameter file specifying the key to set:
AutorotateOff.reg:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AutoRotation
Enable = REG_DWORD 0DWORD
Command to issue on command line with elevated right:
c:\>regini AutorotateOff.reg
Been a while, but this should do the job:
RegistryKey regKey = Registry.LocalMachine.OpenSubKey("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AutoRotation", true);
if(regKey != null)
{
regKey.SetValue("Enable", "0", RegistryValueKind.DWord);
regKey.Close();
}