Click here to Skip to main content
15,909,445 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionneed help with c programming link list structure to write to a binary file Pin
neodeaths19-Dec-07 20:27
neodeaths19-Dec-07 20:27 
GeneralRe: need help with c programming link list structure to write to a binary file Pin
chandu00419-Dec-07 21:21
chandu00419-Dec-07 21:21 
GeneralRe: need help with c programming link list structure to write to a binary file Pin
CPallini19-Dec-07 21:37
mveCPallini19-Dec-07 21:37 
GeneralRe: need help with c programming link list structure to write to a binary file Pin
Cedric Moonen19-Dec-07 21:58
Cedric Moonen19-Dec-07 21:58 
GeneralRe: need help with c programming link list structure to write to a binary file Pin
CPallini19-Dec-07 22:03
mveCPallini19-Dec-07 22:03 
GeneralRe: need help with c programming link list structure to write to a binary file Pin
Christian Graus19-Dec-07 22:11
protectorChristian Graus19-Dec-07 22:11 
GeneralDetection of database Pin
tom groezer19-Dec-07 20:24
tom groezer19-Dec-07 20:24 
Questionmy problem about button bitmap Pin
rajneshmalik19-Dec-07 20:13
rajneshmalik19-Dec-07 20:13 
QuestionRe: my problem about button bitmap Pin
David Crow15-Jan-08 3:08
David Crow15-Jan-08 3:08 
QuestionRe: my problem about button bitmap Pin
littleGreenDude4-Feb-08 8:50
littleGreenDude4-Feb-08 8:50 
GeneralRe: my problem about button bitmap Pin
David Crow4-Feb-08 8:56
David Crow4-Feb-08 8:56 
GeneralRe: my problem about button bitmap [modified] Pin
littleGreenDude4-Feb-08 9:07
littleGreenDude4-Feb-08 9:07 
GeneralRe: my problem about button bitmap Pin
David Crow4-Feb-08 10:10
David Crow4-Feb-08 10:10 
QuestionHow to Split a txt file. Pin
santhoshv8419-Dec-07 19:36
santhoshv8419-Dec-07 19:36 
AnswerRe: How to Split a txt file. Pin
CPallini19-Dec-07 21:16
mveCPallini19-Dec-07 21:16 
Generalerror with a /clr option Pin
tasumisra19-Dec-07 18:56
tasumisra19-Dec-07 18:56 
GeneralRe: error with a /clr option Pin
CPallini19-Dec-07 21:08
mveCPallini19-Dec-07 21:08 
GeneralRe: error with a /clr option Pin
Mark Salsbery20-Dec-07 5:49
Mark Salsbery20-Dec-07 5:49 
GeneralSolution Pin
Tausifahamad Tamboli5-Dec-10 17:45
Tausifahamad Tamboli5-Dec-10 17:45 
GeneralProblem with CreateMutex() and CloseHandle() Pin
ashishbhatt19-Dec-07 18:18
ashishbhatt19-Dec-07 18:18 
Hi All, Smile | :) Smile | :)

I have little much confusion about CreateMutex() and CloseHandle(). I am using these functions to allow not to create multiple instances of the my application.

For that I have written below code...
Here juct consider that InstanceHandler is one Class and m_mutex is of the HANDLE type.
<br />
InstanceHandler::InstanceHandler():m_mutex(NULL)<br />
{<br />
}<br />
<br />
InstanceHandler::~InstanceHandler()<br />
{<br />
	// make sure mutex is cleared as we exit<br />
	Release();<br />
}<br />
<br />
BOOL RTMPInstanceHandler::Init()<br />
{<br />
	// Create the named mutex<br />
	m_mutex = CreateMutex(NULL,FALSE,LPCWSTR(mutexname));<br />
	if(m_mutex == NULL)<br />
        {<br />
	        return FALSE;<br />
        }<br />
<br />
	// Check that the mutex didn't already exist<br />
	if (GetLastError() == ERROR_ALREADY_EXISTS)<br />
	{<br />
		return FALSE;<br />
	}<br />
	return TRUE;<br />
}<br />
<br />
//<br />
// allow mutex to be explicitely cleared<br />
//<br />
DWORD RTMPInstanceHandler::Release()<br />
{<br />
	try <br />
	{ <br />
		CloseHandle(m_mutex);<br />
	}<br />
	catch (...)<br />
	{<br />
		//<br />
		// Release() should be called once from the user code,<br />
		// and a second time by the object's destructor. <br />
		// the second call will cause an exception.<br />
		// we can just ignore it.<br />
		//<br />
	}<br />
<br />
	return GetLastError();<br />
}<br />


Here When I call these function like below....
<br />
<br />
RTMPInstanceHandler instancehan;<br />
        if(!instancehan.Init())<br />
	{<br />
		// We don't allow multiple instances!<br />
		MessageBox(NULL, CString("Another instance of Application is already running!!"), CString("Server Message"), MB_OK);<br />
		instancehan.Release();<br />
	}<br />


And here is my problem,, what happens everything runs complete but when I call Release() function then it executes but does not reomve from the Process list.

And Every time I run application then it shows the message indicating that another Instance is running but CloseHandle() function does not remove process.

If you have any idea then reply me.

Thanks in advance.Rose | [Rose]
GeneralRe: Problem with CreateMutex() and CloseHandle() Pin
Sarath C19-Dec-07 19:18
Sarath C19-Dec-07 19:18 
GeneralRe: Problem with CreateMutex() and CloseHandle() Pin
ashishbhatt19-Dec-07 19:32
ashishbhatt19-Dec-07 19:32 
QuestionRe: Problem with CreateMutex() and CloseHandle() Pin
Kiran Pinjala19-Dec-07 22:31
Kiran Pinjala19-Dec-07 22:31 
GeneralRe: Problem with CreateMutex() and CloseHandle() Pin
Sarath C19-Dec-07 23:03
Sarath C19-Dec-07 23:03 
GeneralRe: Problem with CreateMutex() and CloseHandle() Pin
Kiran Pinjala19-Dec-07 23:11
Kiran Pinjala19-Dec-07 23:11 

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.