Hi Peter,
This is probably the cleanest solution.
It's the usual hassle with null pointers being used in the Windows API. And also trying to avoid unnecessary structure definitions.
To Anonymise the Map type, I pass the address of Map (& Map)
Charles
% GENERIC_WRITE = &H40000000
% GENERIC_READ = &H80000000
% FILE_SHARE_READ = &H1
% OPEN_ALWAYS = 4
Declare Function ReadFile Lib "kernel32.dll" (ByVal hFile As Long, ByVal lpBuffer As any, ByVal nNumberOfBytesToRead As Long, ByRef lpNumberOfBytesRead As Long, ByVal lpOverlapped As any) As Long
Declare Function CloseHandle Lib "kernel32.dll" (ByVal hObject As Long) As Long
Declare Function CreateFile Lib "kernel32.dll" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, ByVal lpSecurityAttributes As any, ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) As Long
Long sys_count
Function LoadFile(byval file as string, byval Dest as any, byval count as long) as long '<-- This Function here!
Long fHandle
fHandle = CreateFile file,
GENERIC_READ or GENERIC_WRITE,
FILE_SHARE_READ,
0,
OPEN_ALWAYS,
128,
0
ReadFile fHandle,Dest,count,sys_count, 0
CloseHandle fHandle
End Function
Dim Map(200) As Byte
LoadFile "map1-1.bin",&Map,100
print map(1)