When I compile the following code in Delphi XE2 for the target platform 64-bit Windows ...
function HKeyToString(_HKey: HKey): string;
begin
case _HKey of
HKEY_CLASSES_ROOT: result := 'HKEY_CLASSES_ROOT'; // do not translate
HKEY_CURRENT_USER: result := 'HKEY_CURRENT_USER'; // do not translate
HKEY_LOCAL_MACHINE: result := 'HKEY_LOCAL_MACHINE'; // do not translate
HKEY_USERS: result := 'HKEY_USERS'; // do not translate
HKEY_PERFORMANCE_DATA: result := 'HKEY_PERFORMANCE_DATA'; // do not translate
HKEY_CURRENT_CONFIG: result := 'HKEY_CURRENT_CONFIG'; // do not translate
HKEY_DYN_DATA: result := 'HKEY_DYN_DATA'; // do not translate
else
Result := Format(_('unknown Registry Root Key %x'), [_HKey]);
end;
end;
... I get warnings for each of the HKEY_-Constants: "W1012 Constant expression violates subrange bounds"
I checked the declarations in Winapi.Windows (with Ctrl+Leftclick on the identifiers):
type
HKEY = type UINT_PTR;
{...}
const
HKEY_CLASSES_ROOT = HKEY(Integer($80000000));
These look fine to me. Why does the compiler still think there is a problem?