[fpc-pascal] THandle in code that must compile also with Delphi

Virgo Pärna virgo.parna at mail.ee
Thu Mar 20 14:25:05 CET 2014


On Thu, 20 Mar 2014 13:02:28 +0100 (CET), Michael Van Canneyt <michael at freepascal.org> wrote:
>
> Shortly said: No. The Delphi API is wrong; It should also return THandle 
> (as that is what Windows CreateFile returns), but probably for historical 
> reasons they still use Integer. 
> With the advent of 64-bit delphi, they could have cleaned up their API, but Alas...
>

    I did try googling and it appears, that in 64 bit Delphi XE2 uses THandle 
as a result type. Anyway, in the case of error, it returns INVALID_HANDLE_VALUE, 
which is DWORD(-1).
   So, under Windows it would be possible to use same code, if you compare result 
against INVALID_HANDLE_VALUE. And you should be able safely cast return value to 
THandle for that (and use variable of that type). 
   I really don't know, how it would work on linux, because sys_open seems to return 
int there.

-- 
Virgo Pärna 
virgo.parna at mail.ee




More information about the fpc-pascal mailing list