标签:style blog color os 文件 re c div
static int MapLogFile(void) { hFile = CreateFile(".\\db.bin", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_WRITE_THROUGH, NULL); if (INVALID_HANDLE_VALUE == hFile) { goto err; } hMap = CreateFileMapping(hFile, NULL, PAGE_READWRITE, 0, MAP_LENGTH, NULL); if(0 == hMap) { goto err_map; } MemAddrBegin = (unsigned char *)MapViewOfFile(hMap, FILE_MAP_ALL_ACCESS, 0, 0, 0); if(0 == MemAddrBegin) { goto err_view; } return 0; err_view: CloseHandle(hMap); err_map: CloseHandle(hFile); err: return -1; } static int UnMapLogFile(void) { UnmapViewOfFile(MemAddrBegin); CloseHandle(hMap); CloseHandle(hFile); return 0; }
标签:style blog color os 文件 re c div
原文地址:http://www.cnblogs.com/JonnyLulu/p/3868444.html