It you call to MapViewOfFile
is actually a call to the Windows API function MapViewOfFile then you should not treat it as a HGLOBAL. It's pointer to an area of memory, and when you've finished with it you need to call UnmapViewOfFile.
Also, the HANDLE
you get back from CreateFileMapping should be closed by calling CloseHandle.