Click here to Skip to main content
15,891,431 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionplotting 3d graphs Pin
Dhyanga25-Jun-09 4:53
Dhyanga25-Jun-09 4:53 
QuestionRe: plotting 3d graphs Pin
David Crow25-Jun-09 5:29
David Crow25-Jun-09 5:29 
QuestionRe: plotting 3d graphs Pin
CPallini25-Jun-09 7:45
mveCPallini25-Jun-09 7:45 
AnswerRe: plotting 3d graphs Pin
Chandrasekharan P25-Jun-09 19:48
Chandrasekharan P25-Jun-09 19:48 
GeneralRe: plotting 3d graphs Pin
kilt26-Jun-09 5:22
kilt26-Jun-09 5:22 
QuestionReading from registry Pin
V K 225-Jun-09 4:45
V K 225-Jun-09 4:45 
AnswerRe: Reading from registry Pin
led mike25-Jun-09 5:17
led mike25-Jun-09 5:17 
AnswerRe: Reading from registry Pin
David Crow25-Jun-09 5:28
David Crow25-Jun-09 5:28 
GeneralRe: Reading from registry Pin
Pavan_Putra25-Jun-09 19:29
Pavan_Putra25-Jun-09 19:29 
AnswerRe: Reading from registry Pin
Pavan_Putra26-Jun-09 3:36
Pavan_Putra26-Jun-09 3:36 
QuestionHow to update a string in C++ MFC CListBox Pin
CodeMacDaddy25-Jun-09 4:31
CodeMacDaddy25-Jun-09 4:31 
QuestionRe: How to update a string in C++ MFC CListBox Pin
led mike25-Jun-09 4:33
led mike25-Jun-09 4:33 
AnswerRe: How to update a string in C++ MFC CListBox Pin
CodeMacDaddy26-Jun-09 8:41
CodeMacDaddy26-Jun-09 8:41 
QuestionRe: How to update a string in C++ MFC CListBox Pin
David Crow25-Jun-09 5:30
David Crow25-Jun-09 5:30 
AnswerRe: How to update a string in C++ MFC CListBox Pin
Rajesh R Subramanian25-Jun-09 7:17
professionalRajesh R Subramanian25-Jun-09 7:17 
AnswerRe: How to update a string in C++ MFC CListBox Pin
Maximilien25-Jun-09 7:21
Maximilien25-Jun-09 7:21 
QuestionDifferent mutex handle even though it was created already? Pin
Souldrift25-Jun-09 3:48
Souldrift25-Jun-09 3:48 
Hi again,

I got another one. This time regarding mutexes. I am using the following locking routine:

HANDLE Thread::Lock( const char* name )
{
	// first convert const char* to LPCWSTR -> for CreateMutex()
	wchar_t buffer[FILENAME_MAX];
	mbstowcs_s( NULL, buffer, FILENAME_MAX, name, FILENAME_MAX-1 );

	HANDLE hMutex = CreateMutex(NULL, 
				FALSE,    
				buffer); 
 
	if (!hMutex)
	{
	      return NULL;
	}
	 
	if (GetLastError() == ERROR_ALREADY_EXISTS)
	{
		// not really important, just for debugging
	}

	WaitForSingleObject(hMutex, INFINITE);

	return hMutex;
}


Now I found out that my locking mechanism does not work properly. And the thing is this: Thread 1 calls the Lock()-function. A Mutex is created and everything is fine. While it is locked the same thread actually (which is an error, but that´s how I found out) calls the Lock()-function again with the same name parameter. CreateMutex returns a DIFFERENT handle this time but the GetLastError query returns ERROR_ALREADY_EXISTS. But since it is a different handle WaitForSingleObject() grants access again, before the first Unlock() call occured.
So how does this work. Shouldn´t I get the same handle everytime I call CreatMutex() with the same parameters? Otherwise I get a new handle everytime and nothing is really ever locked.

Thanks again.

Souldrift
AnswerRe: Different mutex handle even though it was created already? Pin
led mike25-Jun-09 4:29
led mike25-Jun-09 4:29 
AnswerRe: Different mutex handle even though it was created already? Pin
Joe Woodbury25-Jun-09 8:33
professionalJoe Woodbury25-Jun-09 8:33 
AnswerRe: Different mutex handle even though it was created already? Pin
norish25-Jun-09 20:14
norish25-Jun-09 20:14 
QuestionHow to change the background color of an EditBox Pin
Deepu Antony25-Jun-09 3:34
Deepu Antony25-Jun-09 3:34 
AnswerRe: How to change the background color of an EditBox Pin
David Crow25-Jun-09 3:41
David Crow25-Jun-09 3:41 
GeneralRe: How to change the background color of an EditBox Pin
Deepu Antony25-Jun-09 4:12
Deepu Antony25-Jun-09 4:12 
QuestionFile Explorer Properties in MFC/Vista Pin
Software200725-Jun-09 3:16
Software200725-Jun-09 3:16 
QuestionB/B+ tree template Pin
alikalik25-Jun-09 3:03
alikalik25-Jun-09 3:03 

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.