- // Get the file size.
- DWORD size_hi = 0;
- DWORD size_lo = GetFileSize(hpath, &size_hi);
-
- if (size_lo == 0 && size_hi == 0) {
- // A zero-length file cannot be mapped.
- CloseHandle(hpath);
- return path;
- }
-
- // Create a file mapping object.
- HANDLE hmap = CreateFileMapping(hpath, NULL, PAGE_READONLY, 0, 1, NULL);
-
- if (!hmap) {
- CloseHandle(hpath);
- return path;
- }
-
- // Create a file mapping to get the file name.
- void * pmem = MapViewOfFile(hmap, FILE_MAP_READ, 0, 0, 1);
-
- if (!pmem) {
- CloseHandle(hmap);
- CloseHandle(hpath);
- return path;
- }
-