function MapFile():BOOL;stdcall;
begin
Result:=True;
hMappingFile := OpenFileMapping(FILE_MAP_WRITE,False,MappingFileName);
if hMappingFile=0 then
begin
hMappingFile := CreateFileMapping($FFFFFFFF,nil,PAGE_READWRITE,0,SizeOf(TShareMem),MappingFileName);
end;
if hMappingFile=0 then
begin
Result:=False;
Exit;
end;
pShMem := MapViewOfFile(hMappingFile,FILE_MAP_WRITE or FILE_MAP_READ,0,0,0);
if pShMem = nil then
begin
Result:=False;
CloseHandle(hMappingFile);
Exit;
end;
end;
procedure UnMapFile();
begin
UnMapViewOfFile(pShMem);
CloseHandle(hMappingFile);
end;