MSDN says
If a file mapping object is backed by the paging file (CreateFileMapping is called with the hFile parameter set to INVALID_HANDLE_VALUE), the paging file must be large enough to hold the entire mapping. If it is not, MapViewOfFile fails.
But this code works even if the pagefile doesn't exist. Why?
HANDLE mm;
LPVOID addr;
mm = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE | SEC_COMMIT, 0, 1024 * 1024, NULL);
if (mm != NULL) {
addr = MapViewOfFile(mm, FILE_MAP_ALL_ACCESS, 0, 0, 1024 * 1024);
if (addr != NULL) {
MessageBox(0, NULL, NULL, 0);
}
}