Collect anti-dandruff code

Source: Internet
Author: User

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;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.