[Project sorting] Win32 and MFC executable files can only run once

Source: Internet
Author: User

// Method 1: Execute an EXE file that controls the release version only once # In ifndef _ debug // debug version, project properties --> Preprocessor --> preprocessing definition: there are _ debugif (findwindow (null, _ T ("window title") // disadvantages of this method: When you first run a debug version of the EXE file, then, the release EXE file cannot run. The debug version affects the release version. The following method does not show this drawback {return false;} # endif // Method 2: the EXE file that controls the release version can only run once # ifndef _ debughandle hsem = createsemaphore (null, 1, 1, _ T ("softname_single_instance"); If (getlasterror () = error_already_exists) {closehandle (hsem); Return false ;}# endif

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.