Finally… a breakthrough of sorts! Here is what I did…
I changed from the default 64 bit debug game build to a 32 bit windows build. This then exposed the normal project properties I was used to seeing, rather that the very abbreviated version. I turned off all optiizations with /Od. It seems that once you have altered the default settings of project settings, you can go back to a 64 bit build, and you still can see all options.
Then I added the following includes:
#include
#include
#include
#include
to the beginning of my “myprojectPawn.cpp” c++ file
then in the initialization code for myprojectPawn object, I added:
#define BUF_SIZE 256
//TCHAR szName[] = TEXT(“Global\MyFileMappingObject”);
TCHAR szMsg[] = TEXT(“Message from first process.”);
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)
L"mappedfilename"); // name of mapping object
if (hMapFile == NULL)
{
_tprintf(TEXT("Could not create file mapping object (%d).\n"),
GetLastError());
return;
}
pBuf = (LPTSTR)MapViewOfFile(hMapFile, // handle to map object
FILE_MAP_ALL_ACCESS, // read/write permission
0,
0,
BUF_SIZE);
if (pBuf == NULL)
{
_tprintf(TEXT("Could not map view of file (%d).\n"),
GetLastError());
CloseHandle(hMapFile);
return;
}
CopyMemory((PVOID)pBuf, szMsg, (_tcslen(szMsg) * sizeof(TCHAR)));
_getch();
For the first time I’m now getting a valid pointer to the hMapFile.
I can’s say that shared memory is working yet, as I need to keep working, but finally getting a valid pointer back is a big step forward.
Hope this helps…