Option _Explicit

Const BUF_SIZE = 256
Const FILE_MAP_ALL_ACCESS = &HF001F

Declare CustomType Library
    Function OpenFileMapping%& Alias "OpenFileMappingA" (ByVal dwDesiredAccess As _Unsigned Long, Byval bInheritHabndle As Long, lpName As String)
    Function MapViewOfFile%& (ByVal hFileMappingObject As _Offset, Byval dwDesiredAccess As _Unsigned Long, Byval dwFileOffsetHigh As _Unsigned Long, Byval dwFileOffsetLow As _Unsigned Long, Byval dwNumberOfBytesToMap As _Offset)
    Sub UnmapViewOfFile (ByVal lpBaseAddress As _Offset)
    Function GetLastError~& ()
    Sub CloseHandle (ByVal hObject As _Offset)
End Declare

Dim As String szName: szName = "MyFileMappingObject"

Dim As _Offset hMapFile, pBuf

hMapFile = OpenFileMapping(FILE_MAP_ALL_ACCESS, 0, szName)

If hMapFile = 0 Then
    Print "Could not open file mapping object ("; GetLastError; ")."
    End
End If

pBuf = MapViewOfFile(hMapFile, FILE_MAP_ALL_ACCESS, 0, 0, BUF_SIZE)

If pBuf = 0 Then
    Print "Could not map view of file ("; GetLastError; ")."
    CloseHandle hMapFile
    End
End If

Dim As _MEM ppbuf: ppbuf = _Mem(pBuf, BUF_SIZE)

Dim As String buf: buf = Space$(BUF_SIZE)
_MemGet ppbuf, ppbuf.OFFSET, buf

Print buf

UnmapViewOfFile pBuf
CloseHandle hMapFile
