If HKey is unsigned, then yes, the definition should be HKEY(DWORD($80000001)).  I do wonder why Win64 produces that particular error though because the final destination is an unsigned 64-bit integer.

Kit

On 12/02/2023 17:17, Bart via fpc-devel wrote:
Hi,

This code compiles happily for Win32, but refuses to compile for Win64:
====
program test;
{$mode objfpc}
{$h+}

uses
   Registry;

type
   TA = class
   private
     FRootKey: HKey;
   public
     //Win64/X86_64 Error: Range check error while evaluating constants
(18446744071562067969 must be between -2147483648 and 4294967295)
     property RootKey: HKey read FRootKey write FRootKey default
HKEY_CURRENT_USER;  //-2147483647
   end;

begin
end.
===

Is this "by design" or is it a bug?

On Windows HKEY_CURRENT_USER is defined as HKEY(longint($80000001));
HKey is defined as HANDLE = System.THandle = QWord on 64-bit, but it
is DWord on 32-bit.
So infact the value of HKEY_CURRENT_USER would be 2147483649 (as a
DWord) on 32-bit, and 18446744071562067969 (as a QWord) on 64-bit?

Shouldn't HKEY_CURRENT_USER et al. be defined as HKEY(DWORD(somevalue)) instead?

Tested with fpc 3.2.2 and fpc main 3.3.1-2495-g6453af40d8
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to