Those calls are to disable rotation for a WindowsRT application (FKA Metro) which you cannot build with Delphi (yet). Even a Metropolis app is still a desktop app. There is a solution on the Intel site.
Based on feedback from X-Ray I cleaned up the code:
unit MetroDisplayRotation;
(*
* Usage: TMetroDisplayRotation.SetDisplayAutoRotationPreferences(
* TMetroDisplayRotation.ORIENTATION_PREFERENCE_LANDSCAPE or
* TMetroDisplayRotation.ORIENTATION_PREFERENCE_LANDSCAPE_FLIPPED);
*)
interface
type
TMetroDisplayRotation = class
public const
ORIENTATION_PREFERENCE_NONE = $0;
ORIENTATION_PREFERENCE_LANDSCAPE = $1;
ORIENTATION_PREFERENCE_PORTRAIT = $2;
ORIENTATION_PREFERENCE_LANDSCAPE_FLIPPED = $4;
ORIENTATION_PREFERENCE_PORTRAIT_FLIPPED = $8;
class procedure SetDisplayAutoRotationPreferences(ORIENTATION_PREFERENCE: Integer);
end;
implementation
uses
SysUtils, Windows;
{ TMetroDisplayRotation }
class procedure TMetroDisplayRotation.SetDisplayAutoRotationPreferences(
ORIENTATION_PREFERENCE: Integer);
type
TSDARP = procedure(ORIENTATION_PREFERENCE: Integer); stdcall;
var
UserHandle: THandle;
SDARP: TSDARP;
begin
UserHandle := GetModuleHandle('User32.dll');
@SDARP := GetProcAddress(UserHandle, 'SetDisplayAutoRotationPreferences');
if Assigned(SDARP) then
SDARP(ORIENTATION_PREFERENCE);
end;
end.
You will want to make sure you ONLY call this on Windows 8 since that procedure doesn't exist elsewhere.
Usage: TMetroDisplayRotation.SetDisplayAutoRotationPreferences(TMetroDisplayRotation.ORIENTATION_PREFERENCE_LANDSCAPE or TMetroDisplayRotation.ORIENTATION_PREFERENCE_LANDSCAPE_FLIPPED);
Another BAD option is to disable it for the entire tablet. Just go to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AutoRotation
in the registry and change Enable
to 0.