Click here to Skip to main content
15,904,287 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Find element at given index after a number of rotations Pin
CPallini5-Aug-18 20:43
mveCPallini5-Aug-18 20:43 
GeneralRe: Find element at given index after a number of rotations Pin
Tarun Jha5-Aug-18 22:21
Tarun Jha5-Aug-18 22:21 
AnswerRe: Find element at given index after a number of rotations Pin
Richard MacCutchan5-Aug-18 21:24
mveRichard MacCutchan5-Aug-18 21:24 
GeneralRe: Find element at given index after a number of rotations Pin
Tarun Jha5-Aug-18 22:20
Tarun Jha5-Aug-18 22:20 
GeneralRe: Find element at given index after a number of rotations Pin
Richard MacCutchan6-Aug-18 2:49
mveRichard MacCutchan6-Aug-18 2:49 
GeneralRe: Find element at given index after a number of rotations Pin
DRHuff10-Aug-18 6:31
DRHuff10-Aug-18 6:31 
QuestionTell me about the c programming languages Pin
Member 139375164-Aug-18 17:29
Member 139375164-Aug-18 17:29 
AnswerRe: Tell me about the c programming languages Pin
Victor Nijegorodov4-Aug-18 20:44
Victor Nijegorodov4-Aug-18 20:44 
AnswerRe: Tell me about the c programming languages Pin
jfbode10297-Aug-18 7:08
jfbode10297-Aug-18 7:08 
QuestionForward error correction in C-programming applied to non-streaming data? Pin
arnold_w4-Aug-18 19:23
arnold_w4-Aug-18 19:23 
AnswerRe: Forward error correction in C-programming applied to non-streaming data? Pin
leon de boer5-Aug-18 14:25
leon de boer5-Aug-18 14:25 
QuestionDid I Overlook Something, or is the LTCG Document Page Actually Outdated? Pin
David A. Gray4-Aug-18 11:32
David A. Gray4-Aug-18 11:32 
Questionhow to query a previous query Pin
piano00113-Aug-18 23:03
piano00113-Aug-18 23:03 
AnswerRe: how to query a previous query Pin
Victor Nijegorodov4-Aug-18 2:02
Victor Nijegorodov4-Aug-18 2:02 
QuestionCondition variable question Pin
samzcs3-Aug-18 7:31
samzcs3-Aug-18 7:31 
AnswerRe: Condition variable question Pin
Richard MacCutchan3-Aug-18 21:09
mveRichard MacCutchan3-Aug-18 21:09 
GeneralRe: Condition variable question Pin
focusdoit4-Aug-18 2:39
focusdoit4-Aug-18 2:39 
GeneralRe: Condition variable question Pin
Richard MacCutchan4-Aug-18 3:19
mveRichard MacCutchan4-Aug-18 3:19 
GeneralRe: Condition variable question Pin
focusdoit4-Aug-18 3:22
focusdoit4-Aug-18 3:22 
GeneralRe: Condition variable question Pin
Richard MacCutchan4-Aug-18 3:31
mveRichard MacCutchan4-Aug-18 3:31 
GeneralRe: Condition variable question Pin
focusdoit4-Aug-18 8:25
focusdoit4-Aug-18 8:25 
GeneralRe: Condition variable question Pin
Richard MacCutchan4-Aug-18 9:32
mveRichard MacCutchan4-Aug-18 9:32 
GeneralRe: Condition variable question Pin
focusdoit4-Aug-18 16:30
focusdoit4-Aug-18 16:30 
GeneralRe: Condition variable question Pin
Richard MacCutchan4-Aug-18 20:57
mveRichard MacCutchan4-Aug-18 20:57 
QuestionA Problem in Writing Shared Memory to windows from a C++ application Pin
D_code_writer2-Aug-18 5:00
D_code_writer2-Aug-18 5:00 
Hey Guys,

I'm writing an application in C++ that needs to write shared memory to windows and I've hit a stumbling block.

Even though I'm not getting any error messages (I've stepped through with the debugger) it would appear nothing is writing to shared memory. Here is the code that writes the shared memory,

void Write_Physics(PhysicsStruct *s_physics)
{
//	Create the shared memory
	TCHAR szName[] = TEXT("Local\\physics");
	hMapFile = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, sizeof(PhysicsStruct), szName);
	if (!hMapFile)
	{
		return;
	}

	//	Open the buffer for file read and write
	mapFileBuffer = (unsigned char*)MapViewOfFile(m_physics.hMapFile, FILE_MAP_ALL_ACCESS, 0, 0, sizeof(PhysicsStruct));
	if (!mapFileBuffer)
	{
		return;
	}
	
	//	Copy the physics pointer over
	CopyMemory(mapFileBuffer,s_physics,sizeof(PhysicsStruct));
	//_getch();
	

	//	Write the shared memory
	UnmapViewOfFile(m_physics.mapFileBuffer);
	CloseHandle(m_physics.hMapFile);
}


My difficulty is that when I try another process to read the shared memory nothing is happening. For completeness here is the code that reads the structure from the shared memory,
void Read_Physics(PhysicsStruct *s_physics)
{
	//	Create the shared memory
	TCHAR szName[] = TEXT("Local\\physics");
	hMapFile = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, sizeof(PhysicsStruct), szName);
	if (!m_physics.hMapFile)
	{
		return;
	}

	//	Open the buffer for file read and write
	mapFileBuffer = (unsigned char*)MapViewOfFile(hMapFile, FILE_MAP_READ, 0, 0, sizeof(PhysicsStruct));
	if (!mapFileBuffer)
	{
		return;
	}

	s_physics = (PhysicsStruct*)mapFileBuffer;

	//	Write the shared memory
	UnmapViewOfFile(mapFileBuffer);
	CloseHandle(hMapFile);	
}
//-----------------------------------------------------------------------


If anyone has any suggestions it would be greatly appreciated. What the problem resembles is like trying to write something to file and forgetting the fprintf or file write commands.

Thanks in advance guys.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.