Click here to Skip to main content
16,005,141 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionMullti line in combobox Pin
sheshidar18-Jul-08 18:42
sheshidar18-Jul-08 18:42 
AnswerRe: Mullti line in combobox Pin
Ștefan-Mihai MOGA18-Jul-08 21:50
professionalȘtefan-Mihai MOGA18-Jul-08 21:50 
QuestionRe: Mullti line in combobox Pin
David Crow19-Jul-08 11:20
David Crow19-Jul-08 11:20 
QuestionHow to install dao database application? Pin
includeh1018-Jul-08 13:22
includeh1018-Jul-08 13:22 
AnswerRe: How to install dao database application? Pin
Garth J Lancaster18-Jul-08 13:48
professionalGarth J Lancaster18-Jul-08 13:48 
AnswerRe: How to install dao database application? Pin
bob1697219-Jul-08 16:50
bob1697219-Jul-08 16:50 
QuestionCross-session detection of running programs Pin
luweewu18-Jul-08 10:20
luweewu18-Jul-08 10:20 
AnswerRe: Cross-session detection of running programs [modified] Pin
Mark Salsbery18-Jul-08 11:33
Mark Salsbery18-Jul-08 11:33 
What about using CreateMutex() to create a named mutex?
A named mutex is system-wide in scope and can be obtained
atomically by any process.

You can use code similar to the following. The same code can be used
to prevent more than one instance of an app and to detect if it's running already...
	HANDLE hMutex;
	hMutex = ::CreateMutex(NULL, TRUE, _T("Global\\MutexNameUniqueToSomeApplication"));
	if (hMutex)
	{
		DWORD err = ::GetLastError();
		if (ERROR_SUCCESS == err)
		{
			// We are the first to create the mutex
		}
		else if (ERROR_ALREADY_EXISTS == err)
		{
			// mutex was already created by someone else!
		}
	}


... (at exit)
	if (hMutex)
		::CloseHandle(hMutex);

*edit*<br />
Bug fix - thanks Randor!


Mark Salsbery
Microsoft MVP - Visual C++

Java | [Coffee]

modified on Saturday, July 19, 2008 1:19 PM

GeneralRe: Cross-session detection of running programs Pin
Randor 18-Jul-08 13:56
professional Randor 18-Jul-08 13:56 
GeneralRe: Cross-session detection of running programs Pin
Mark Salsbery19-Jul-08 7:19
Mark Salsbery19-Jul-08 7:19 
AnswerRe: Cross-session detection of running programs Pin
kinar18-Jul-08 12:09
kinar18-Jul-08 12:09 
GeneralRe: Cross-session detection of running programs Pin
Stephen Hewitt20-Jul-08 13:38
Stephen Hewitt20-Jul-08 13:38 
GeneralRe: Cross-session detection of running programs Pin
kinar20-Jul-08 18:19
kinar20-Jul-08 18:19 
GeneralRe: Cross-session detection of running programs Pin
luweewu22-Jul-08 11:14
luweewu22-Jul-08 11:14 
AnswerRe: Cross-session detection of running programs Pin
luweewu24-Jul-08 7:31
luweewu24-Jul-08 7:31 
AnswerRe: Cross-session detection of running programs Pin
Big Daddy Farang18-Jul-08 12:23
Big Daddy Farang18-Jul-08 12:23 
QuestionHelp update window display Pin
Kwanalouie18-Jul-08 10:19
Kwanalouie18-Jul-08 10:19 
AnswerRe: Help update window display Pin
CPallini18-Jul-08 11:54
mveCPallini18-Jul-08 11:54 
QuestionCListCtrl and mods to bkgrnd colour Pin
john john mackey18-Jul-08 9:53
john john mackey18-Jul-08 9:53 
QuestionAdding ODBC RecordSet class to Mainfrm class Pin
Cozmo2318-Jul-08 8:38
Cozmo2318-Jul-08 8:38 
AnswerRe: Adding ODBC RecordSet class to Mainfrm class Pin
Mark Salsbery18-Jul-08 8:55
Mark Salsbery18-Jul-08 8:55 
AnswerRe: Adding ODBC RecordSet class to Mainfrm class Pin
David Crow18-Jul-08 10:04
David Crow18-Jul-08 10:04 
GeneralRe: Adding ODBC RecordSet class to Mainfrm class Pin
Cozmo2319-Jul-08 8:01
Cozmo2319-Jul-08 8:01 
QuestionSerial Com controlling DTR & RTS Pin
aei_totten18-Jul-08 8:05
aei_totten18-Jul-08 8:05 
AnswerRe: Serial Com controlling DTR & RTS Pin
aei_totten18-Jul-08 8:38
aei_totten18-Jul-08 8:38 

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.