Skip to content

Instantly share code, notes, and snippets.

@pythongo1
Created June 22, 2019 14:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pythongo1/c7e0465aad9cb9feb98949c42ede1d25 to your computer and use it in GitHub Desktop.
Save pythongo1/c7e0465aad9cb9feb98949c42ede1d25 to your computer and use it in GitHub Desktop.
#include <windows.h>
#include <windows.h>
#include <stdio.h>
#include <conio.h>
#include <tchar.h>
#pragma comment(lib, "user32.lib")
int main()
{
HANDLE hMapFile;
LPCTSTR pBuf;
hMapFile = OpenFileMapping(
FILE_MAP_ALL_ACCESS, // read/write access
FALSE, // do not inherit the name
TEXT("SharedObject")); // name of mapping object
if (hMapFile == NULL)
{
printf(TEXT("Could not open file mapping object (%d).\n"), GetLastError());
return 1;
}
pBuf = (LPTSTR) MapViewOfFile(hMapFile, // handle to map object
FILE_MAP_ALL_ACCESS, // read/write permission
0,
0,
0);
if (pBuf == NULL)
{
printf(TEXT("Could not map view of file (%d).\n"), GetLastError());
CloseHandle(hMapFile);
return 1;
}
printf("the catalan number is \n%s",pBuf);
UnmapViewOfFile(pBuf);
CloseHandle(hMapFile);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment