المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Problem with use of Mutex and System Tray Icon Together.



C++ Programming
08-08-2009, 09:53 AM
Hi all,

I m working on SDI type Application, Here i m Using Mutex to prevent multiple instances of my exe.

i m using this code for mutex.


HANDLE hMutex = ::CreateMutex(NULL, TRUE, _T("_315FrYu76A_GlobalMainMutex__315FrYu76A"));
switch(::GetLastError())
{
case ERROR_SUCCESS:
// Mutex created successfully. There is no instance running
break;

case ERROR_ALREADY_EXISTS:
// Mutex already exists so there is a running instance of our app.
return FALSE;

default:
// Failed to create mutex by unknown reason
return FALSE;
}





for system tray icon i m taking help of this article.

Adding Icons to the System Tray (http://www.codeproject.com/KB/shell/systemtray.aspx)[^ (http://www.codeproject.com/KB/shell/systemtray.aspx)]

My problem is that if application is already running and its in hide mode and icon present in system tray,now when i click on my exe than its not open becoz of mutex.

i want when application is already running or its hide than if i click on exe than the hide application show.

please tell me how can i do this.

if possible please explain me with any example .

thanks in advance.

To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.