[fpc-devel] What is CreateFileMapping?

Jonas Maebe jonas.maebe at elis.ugent.be
Thu Dec 11 20:49:02 CET 2008

On 11 Dec 2008, at 19:39, Gilles MARCOU wrote:

> I am converting a small project from Delphi to Free Pascal. I am  
> working
> on a Linux (Debian) box. In several places, the software seems to call
> to external applications an uses this kind of command:
> var
>  smfMemHnd : HWND;
> ...
> smfMemHnd := CreateFileMapping(HWND($FFFFFFFF), nil, PAGE_READWRITE,  
> 0,
> memFileSize , memFileName);
> Free Pascal seems unable to find the function CreateFileMapping. While
> browsing the RTL, this function seems to be part of some Windows  
> related
> library.
> I have two questions:
> 1/ Which unit shall I add to my .pas file for FPC to find this  
> function?
> 2/ If this is Windows specific, how do I manage this on other
> architectures?

It is Windows-specific. On *nix platforms (such as Linux), you can  
probably use fpmmap instead (it's in the baseunix unit). See http://www.freepascal.org/docs-html/rtl/baseunix/fpmmap.html 
, or "man mmap", for more information. Note that it expects a file  
descriptor rather than a file name (but there's an example program on  
that page that demonstrates how to use it).


More information about the fpc-devel mailing list