Search code examples
delphidelphi-10.2-tokyo

Casting with TULargeInteger in delphi 10.2 Tokyo differ from previous version


Casting with TULargeInteger with new compiler 10.2 missing attribut LowPart and HighPart.

uses Winapi.Windows;

    function RetLargeInt: Int64;
    var
      ALow: DWORD;

    begin
      {Do Something
        With ALow
      }
      TULargeInteger(Result).LowPart := ALow; {Missing 'LowPart'}
    end;

    procedure AProc;
    var
     ALocalInt: Int64;
    begin
      ALocalInt := RetLargeInt;
      {Do Something}
    end;

Solution

  • In 10.2 Tokyo, the declaration of TULargeInteger has changed from:

    TULargeInteger = ULARGE_INTEGER;
    

    to :

    TULargeInteger = UInt64;
    

    This means that you can no longer access the ULARGE_INTEGER record fields that exposes LowPart.

    ULARGE_INTEGER = record
        case Integer of
        0: (
          LowPart: DWORD;
          HighPart: DWORD);
        1: (
          QuadPart: ULONGLONG);
      end;
    

    You can change the code to use ULARGE_INTEGER instead:

    ULARGE_INTEGER(Result).LowPart := ALow;