Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <windows.h>
- #include <stdio.h>
- #include <conio.h>
- #include <iostream>
- #include <tchar.h>
- #include <string.h>
- using namespace std;
- #define BUF_SIZE 256
- TCHAR szName[] = TEXT("Global\\MyFileMappingObject");
- int _tmain()
- {
- HANDLE hMapFile;
- LPCTSTR pBuf;
- hMapFile = CreateFileMapping(
- INVALID_HANDLE_VALUE, // use paging file
- NULL, // default security
- PAGE_READWRITE, // read/write access
- 0, // maximum object size (high-order DWORD)
- BUF_SIZE, // maximum object size (low-order DWORD)
- szName); // name of mapping object
- if (hMapFile == NULL)
- {
- _tprintf(TEXT("Could not create file mapping object (%d).\n"),
- GetLastError());
- return 1;
- }
- pBuf = (LPTSTR)MapViewOfFile(hMapFile, // chwytak do obiektu
- FILE_MAP_ALL_ACCESS, // read/write pozwolenie
- 0, //gorny rozmar
- 0, //dolny rozmoar
- BUF_SIZE); // max ilsoc
- if (pBuf == NULL)
- {
- _tprintf(TEXT("Could not map view of file (%d).\n"),
- GetLastError());
- CloseHandle(hMapFile);
- return 1;
- }
- //_getch();
- while (1)
- {
- char arr[5] = { 'a', 'b', 'c', 'd', 'e' };
- char *ptr = arr;
- TCHAR szMsg[] = TEXT(&ptr);
- CopyMemory((PVOID)pBuf, szMsg, (_tcslen(szMsg) * sizeof(TCHAR))); // gdzie , skąd , ile
- }
- UnmapViewOfFile(pBuf);
- CloseHandle(hMapFile);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement