Programs run only once in wince. net

Source: Internet
Author: User

 

1 using system;
2 using system. runtime. interopservices;
3
4 class mutex
5 {
6 [dllimport ("coredll. dll")]
7 Private Static extern int getlasterror ();
8
9 [dllimport ("coredll. dll")]
10 Private Static extern int releasemutex (intptr hmutex );
11
12 [dllimport ("coredll. dll")]
13 Private Static extern intptr createmutex (
14 security_attributes lpmutexattributes,
15 bool binitialowner, string lpname );
16
17 [structlayout (layoutkind. Sequential)]
18 public class security_attributes
19 {
20 public int nlength;
21 public int lpsecuritydescriptor;
22 public int binherithandle;
23}
24
25 private const int error_already_exists = 0183;
26
27 public static void run ()
28 {
29 intptr hmutex = createmutex (null, false, "zjs_fj ");
30 if (getlasterror ()! = Error_already_exists)
31 {
32 system. Windows. Forms. application. Run (New form1 ());
33 return;
34}
35 else
36 {
37 releasemutex (hmutex );
38 return;
39}
40}
41} // class
42

 

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.