void CycleScreenAngle(void) { DEVMODE dm; DWORD dwCurrentAngle; // Set up to get the current angle memset(&dm, 0, sizeof(DEVMODE)); dm.dmSize = sizeof(DEVMODE); dm.dmFields = DM_DISPLAYORIENTATION; // Get the current angle ChangeDisplaySettingsEx(NULL, &dm, NULL, CDS_TEST, NULL); dwCurrentAngle = dm.dmDisplayOrientation; RETAILMSG(DEBUG_VERB, (TEXT("CycleScreenAngle: Current = %d\r\n"), dwCurrentAngle)); memset(&dm, 0, sizeof(DEVMODE)); dm.dmSize = sizeof(DEVMODE); dm.dmFields = DM_DISPLAYORIENTATION; // Base the new angle on the current angle if (DMDO_0 == dwCurrentAngle) { dm.dmDisplayOrientation = DMDO_90; } else if (DMDO_90 == dwCurrentAngle) { dm.dmDisplayOrientation = DMDO_180; } else if (DMDO_180 == dwCurrentAngle) { dm.dmDisplayOrientation = DMDO_270; } else if (DMDO_270 == dwCurrentAngle) { dm.dmDisplayOrientation = DMDO_0; } RETAILMSG(DEBUG_VERB, (TEXT("CycleScreenAngle: New = %d\r\n"), dm.dmDisplayOrientation)); ChangeDisplaySettingsEx(NULL, &dm, NULL, 0, NULL); } Here’s some c# code: public enum Orientation { /// /// Represents portrait orientation. /// Portrait, /// /// Represents landscape orientation. /// Landscape } 1. public static Orientation Orientation 2. { 3. get 4. { 5. var screenOrientation = SystemSettings.ScreenOrientation; 6. 7. if (screenOrientation == ScreenOrientation.Angle0 || screenOrientation == ScreenOrientation.Angle180) 8. { 9. return Orientation.Portrait; 10. } 11. 12. return Orientation.Landscape; 13. } 14. } 15. 16. /// 17. /// Forces the portrait. 18. /// 19. public static void ForcePortrait() 20. { 21. try 22. { 23. if (Orientation != Orientation.Portrait) 24. { 25. SystemSettings.ScreenOrientation = ScreenOrientation.Angle0; 26. } 27. } 28. catch (Exception ex) 29. { 30. ErrorLogger.Error(ex.Message, ex); 31. } 32.