If "calendar"ProgramAlready running. You can use the followingCodeFind the program and display it to the front.
Hwnd hprogramwnd =: findwindow (null, l "calendar ");
If (hprogramwnd)
{
This-> m_ncmdshow = sw_show;
//: Bringwindowtotop (hprogramwnd );
// Setwindowpos (hprogramwnd, hwnd_notopmost, 0, 0, 30, 50, swp_nosize | swp_nomove );
Setwindowpos (hprogramwnd, hwnd_topmost,: getsystemmetrics (sm_cxscreen),: getsystemmetrics (sm_cyscreen)-26, swp_showwindow );
}
Create a program mutex for a program. When you run the following code, create a mutex. If you have already run the program, you Can prefix it and exit. For users, it is like transferring the original running program from the background to the foreground.
// Only one program is running
// Create a process mutex gpsguid
Handle m_hmutex = createmutex (null, false, _ T ("gpsgui "));
If (m_hmutex = NULL)
{
Return false;
}
// If the program already exists and is running
If (getlasterror () = error_already_exists)
{
Hwnd hprogramwnd =: findwindow (null, l "gpsgui ");
If (hprogramwnd)
{
This-> m_ncmdshow = sw_show;
//: Bringwindowtotop (hprogramwnd );
// Setwindowpos (hprogramwnd, hwnd_notopmost, 0, 0, 30, 50, swp_nosize | swp_nomove );
Setwindowpos (hprogramwnd, hwnd_topmost,: getsystemmetrics (sm_cxscreen),: getsystemmetrics (sm_cyscreen)-26, swp_showwindow );
}
// Close the process mutex
Closehandle (m_hmutex );
M_hmutex = NULL;
Return false;
}