공부/API
MMF 기본
잠수함토끼
2008. 8. 29. 14:43
#undef UNICODE #include#include int main(void) { //파일의 핸들을 얻어온다. HANDLE hFile = CreateFileA("c:\\love.txt",GENERIC_READ, 0,NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,NULL); if(NULL==hFile) printf("error\n"); //파일의 핸들을 기반으로 memorymapping을 한다. HANDLE hFileMaped=CreateFileMapping(hFile,NULL,PAGE_READONLY,0,0,NULL); if(NULL==hFileMaped) printf("error\n"); //파일 멥을 메모리에 올리자. char* pfile=(char*)MapViewOfFile(hFileMaped, FILE_MAP_READ, 0,0,0); if(NULL==pfile) printf("error\n"); printf(pfile); UnmapViewOfFile(pfile); CloseHandle(hFileMaped); CloseHandle(hFile); return 0; }