When my code (below) is executed, a error message is triggered which says "The operation completed successfully." To give this some context, hFileMap is valid; I have checked this with my debugger, and other operations can easily be performed correctly on this handle that yield correct results. The only weird thing is that MapViewOfFile returns a null pointer. Since I use this memory mapped file as a way of communicating between two applications, this function is critical. Please note that I am no beginner to coding, and this same program successfully implements multi-threading as well as on-the-fly (dynamic) function creation (also called reflection) for its scripting engine.

static char *Buff = NULL;
	static HANDLE hFileMap;
	int jointCount = 0;
	int startingBone = msModel_GetBoneCount(pModel);

	msBone *currentBone = NULL;


	UINT_PTR threadId;
	int value = 10;

	hFileMap = OpenFileMapping(PAGE_READONLY, true, "animationMemFileClientOut");
	if (hFileMap == NULL)
		return 0;

	char* buffer = (char *)MapViewOfFile(hFileMap, FILE_MAP_READ, 0, 0, 0);

	if (buffer == NULL)
		DWORD pMessage = GetLastError();

		buffer = new char[128];

		MessageBox(NULL, (LPCSTR)buffer, "Error", MB_OK);

Edited 6 Years Ago by rothn: n/a

>> a error message is triggered which says "The operation completed successfully."

This happens because you are using FormatMessage() incorrectly.

See Retrieving the Last-Error Code. Note how the value returned by GetLastError() is passed to FormatMessage() .

And to fix the error, make this change: hFileMap = OpenFileMapping( /*PAGE_READONLY*/ FILE_MAP_READ, true, "animationMemFileClientOut");

Edited 6 Years Ago by vijayan121: n/a

This article has been dead for over six months. Start a new discussion instead.