Click here to Skip to main content
15,892,005 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: CEditView operation rediculously Slows down in Windows 7 Pin
Vijjuuu.10-Nov-11 5:00
Vijjuuu.10-Nov-11 5:00 
GeneralRe: CEditView operation rediculously Slows down in Windows 7 Pin
Richard MacCutchan10-Nov-11 6:23
mveRichard MacCutchan10-Nov-11 6:23 
GeneralRe: CEditView operation rediculously Slows down in Windows 7 Pin
Vijjuuu.10-Nov-11 6:28
Vijjuuu.10-Nov-11 6:28 
AnswerRe: CEditView operation rediculously Slows down in Windows 7 Pin
David Crow10-Nov-11 2:46
David Crow10-Nov-11 2:46 
GeneralRe: CEditView operation rediculously Slows down in Windows 7 Pin
Vijjuuu.10-Nov-11 4:59
Vijjuuu.10-Nov-11 4:59 
SuggestionRe: CEditView operation rediculously Slows down in Windows 7 Pin
David Crow10-Nov-11 5:05
David Crow10-Nov-11 5:05 
GeneralRe: CEditView operation rediculously Slows down in Windows 7 Pin
Vijjuuu.10-Nov-11 5:08
Vijjuuu.10-Nov-11 5:08 
QuestionHow to repeat call to MapViewOfFile with a different range on a file, to write bigger buffer.? Pin
G Haranadh9-Nov-11 17:52
G Haranadh9-Nov-11 17:52 
Hi All,
I am using shared memory functions, to write data into file.
Problem:
When I want to write the buffer 10MB, to file using below function, i am able to write only in first iteration, second iteration i could not write buffer next part in to memory. please help me if any suggestion. or any wrong in the below code. i have only control on this part. i dont have control in other part which has CreateFileMapping.

any thing i need to change in "dwFileOffsetLow" or "dwFileOffsetHigh". from second iteration onwards the
"MapViewOfFile" returning null. Some place i got input as I need to repeate call MapViewOfFile different ranges. But how to call, any help?

WriteBuffer function i defined as follows:
C++
BOOL CWriter::Write(char* pMemName,char* pBinary,long lBuffSize)
{
	long lUnitSize = MEM_UNIT_SIZE;
	if( lBuffSize <= 0 && lUnitSize <=0 )
		return FALSE;
	//Open named file mapping object.
	HANDLE hFileMMF = OpenFileMapping(FILE_MAP_WRITE,FALSE,pMemName);
	
	if(hFileMMF == NULL)
	{
		DWORD dwErr = GetLastError();
		return (FALSE);
	}

	int nCount = 0;
	nCount = (int)(lBuffSize / lUnitSize) + 1;
	for(int n =0; n<nCount; ++n)
	{
		DWORD dwFileOffsetHigh = 0;
		DWORD dwFileOffsetLow = lUnitSize*n;

		// Map  view of a file mapping into the address space of a calling process.
		LPVOID pViewMMFFile = MapViewOfFile(hFileMMF,
							FILE_MAP_WRITE,
							dwFileOffsetHigh,
							dwFileOffsetLow,
							MEM_UNIT_SIZE);
		if( pViewMMFFile == NULL )
			return (FALSE);
		CMutex mutex (FALSE, _T("MIPSMMMutexWriter"));
		CString strTemp;
		strTemp.Format("%s",pBinary);
		
		// Lock memory, shared amongst processes
		mutex.Lock();
		try
		{
			CopyMemory(pViewMMFFile,pBinary,lUnitSize); // write 
		}
		catch(CException e)
		{
			DWORD dw = ::GetLastError();
			TRACE1("%d",dw);
		}
		mutex.Unlock(); // Unlock shared memory
		//Unmap mapped view of a file from the calling process's address space.
		UnmapViewOfFile(pViewMMFFile);
	}
	return (TRUE);
}


Nice talking to you. Blush | :O
If you judge people, you have no time to love them. -- Mother Teresa


modified 10-Nov-11 0:02am.

AnswerRe: How to repeat call to MapViewOfFile with a different range on a file, to write bigger buffer.? Pin
peterchen9-Nov-11 22:03
peterchen9-Nov-11 22:03 
QuestionRe: How to repeat call to MapViewOfFile with a different range on a file, to write bigger buffer.? Pin
G Haranadh14-Nov-11 0:11
G Haranadh14-Nov-11 0:11 
GeneralRe: How to repeat call to MapViewOfFile with a different range on a file, to write bigger buffer.? Pin
peterchen14-Nov-11 20:50
peterchen14-Nov-11 20:50 
QuestionRe: How to repeat call to MapViewOfFile with a different range on a file, to write bigger buffer.? Pin
G Haranadh14-Nov-11 21:45
G Haranadh14-Nov-11 21:45 
Questionwin32 Listbox 101, Get Selected Value Pin
jkirkerx9-Nov-11 15:15
professionaljkirkerx9-Nov-11 15:15 
QuestionRe: win32 Listbox 101, Get Selected Value Pin
David Crow9-Nov-11 17:28
David Crow9-Nov-11 17:28 
AnswerRe: win32 Listbox 101, Get Selected Value Pin
jkirkerx10-Nov-11 5:27
professionaljkirkerx10-Nov-11 5:27 
AnswerRe: win32 Listbox 101, Get Selected Value Pin
jkirkerx10-Nov-11 5:45
professionaljkirkerx10-Nov-11 5:45 
GeneralRe: win32 Listbox 101, Get Selected Value Pin
David Crow10-Nov-11 5:50
David Crow10-Nov-11 5:50 
GeneralRe: win32 Listbox 101, Get Selected Value Pin
jkirkerx10-Nov-11 6:43
professionaljkirkerx10-Nov-11 6:43 
QuestionMFC new should throw Pin
bob169729-Nov-11 11:42
bob169729-Nov-11 11:42 
AnswerRe: MFC new should throw Pin
Chris Losinger9-Nov-11 15:07
professionalChris Losinger9-Nov-11 15:07 
AnswerRe: MFC new should throw Pin
Richard MacCutchan9-Nov-11 22:33
mveRichard MacCutchan9-Nov-11 22:33 
GeneralRe: MFC new should throw Pin
bob1697210-Nov-11 3:49
bob1697210-Nov-11 3:49 
GeneralRe: MFC new should throw Pin
Richard MacCutchan10-Nov-11 6:21
mveRichard MacCutchan10-Nov-11 6:21 
GeneralRe: MFC new should throw Pin
bob1697210-Nov-11 7:28
bob1697210-Nov-11 7:28 
GeneralRe: MFC new should throw Pin
Richard MacCutchan10-Nov-11 11:27
mveRichard MacCutchan10-Nov-11 11:27 

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.