Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!
Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.
Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is no translation for that post!
[Solved] Lazarus - Convert Cardinal Lo and Hi to Int64 the easy way
Delphi, Lazarus, Free Pascal
(@hans)
Famed Member Admin
Joined: 12 years ago
Posts: 2859
Topic starter
April 6, 2019 12:35 AM
One of those things I do not do every day ...
So I have a record, from an external library, that holds a 32 bit Lo and Hi (cardinal) to represent a Int64 number ...
How do I convert this to a regular Int64 so I can work with it?
Lazarus Pascal comes with TONS of handy little tools, and Int64Rec is of of them.
Int64Rec, found in the unit SysUtils, is a Record describing an Int64 value and can be used as such by using typecasting:
var
MyVar:Int64;
...
begin
...
Int64Rec(MyVar).Hi := somerecord.hi32;
Int64Rec(MyVar).Lo := somerecord.lo32;
...
WriteLn(IntToStr(MyVar)); // do something with the value of MyVar
...
By assigning the Hi and Lo values, the actual value of MyVar is now defined.