偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

淺談如何讓W(xué)indows Mobile只運(yùn)行一個(gè)實(shí)例

移動(dòng)開發(fā)
本文將簡單談?wù)勅绾巫學(xué)indows Mobile只運(yùn)行一個(gè)實(shí)例,其中主要用到的互斥的概念。文末作者還提出了自己的一些問題,希望大家積極討論。

因?yàn)橐粋€(gè)項(xiàng)目的需求,要實(shí)現(xiàn)程序只有一個(gè)實(shí)例運(yùn)行。在網(wǎng)上搜了很久,最后在CSDN上面看到一回復(fù)。得到啟示,完成該功能。

主要用的是互斥對象來實(shí)現(xiàn)。代碼如下:

  1. staticclassProgram  
  2. {  
  3. [DllImport("coredll.Dll",SetLastError=true)]  
  4. privatestaticexternIntPtrCreateMutex(SECURITY_ATTRIBUTESlpMutexAttributes,boolbInitialOwner,stringlpName);  
  5.  
  6. [DllImport("coredll.Dll",SetLastError=true)]  
  7. privatestaticexternintReleaseMutex(IntPtrhMutex);  
  8.  
  9. [StructLayout(LayoutKind.Sequential)]  
  10. publicclassSECURITY_ATTRIBUTES  
  11. {  
  12. publicintnLength;  
  13. publicintlpSecurityDescriptor;  
  14. publicintbInheritHandle;  
  15. }  
  16.  
  17. constintERROR_ALREADY_EXISTS=0183;  
  18.  
  19. ///<summary> 
  20. ///應(yīng)用程序的主入口點(diǎn)。  
  21. ///</summary> 
  22. [MTAThread]  
  23. staticvoidMain()  
  24. {  
  25. IntPtrhMutex=CreateMutex(null,false,"StandardWorkMan");  
  26. if(Marshal.GetLastWin32Error()!=ERROR_ALREADY_EXISTS)  
  27. {  
  28. Application.Run(newFormWorkList());  
  29. }  
  30. else  
  31. {  
  32. MessageBox.Show("已經(jīng)啟動(dòng)了一個(gè)程序,請勿重復(fù)打開","系統(tǒng)提示",  
  33. MessageBoxButtons.OKCancel,MessageBoxIcon.Asterisk,MessageBoxDefaultButton.Button1);  
  34. ReleaseMutex(hMutex);  
  35. Application.Exit();  
  36. }  
  37. }  

上面代碼完全正常,我的問題是大部分自己很早就寫出來了。只是問題在下面:

  1. [DllImport("coredll.Dll",SetLastError=true)]  
  2. privatestaticexternintGetLastError();  
  3.  
  4. .  
  5.  
  6. if(GetLastError()!=ERROR_ALREADY_EXISTS)  
  7. {  
  8. Application.Run(newFormWorkList());  

我用的是平臺(tái)調(diào)用里面的GetLastError(),結(jié)果一直出不來想要的效果。調(diào)試時(shí)發(fā)現(xiàn)無論打開多少個(gè)實(shí)例,GetLastError()的值一直都是6(INVALID_HANDLE_VALUE)????很不解。望明白的人說明一下。謝謝。

【編輯推薦】

  1. Windows Mobile 6.5將在5月推出
  2. 微軟稱已完成Windows Mobile6.5開發(fā)
  3. 微軟開始組織開發(fā)大型Windows Mobile應(yīng)用程序
  4. 微軟將推出Windows Mobile應(yīng)用軟件商店
  5. Windows Mobile上實(shí)現(xiàn)自動(dòng)拼寫和匹配
責(zé)任編輯:彭凡 來源: cnblogs
相關(guān)推薦

2009-10-27 09:05:44

Windows 7進(jìn)程查看

2019-12-11 11:08:51

Windows 10Windows 10

2011-06-09 09:31:40

Qt 實(shí)例

2012-06-01 10:23:47

Mobile Site優(yōu)化

2009-09-18 08:58:09

Windows Mob社交平臺(tái)

2023-12-18 08:23:12

CSI插件Kubernetes

2017-11-13 13:33:09

MySQL全備份恢復(fù)表

2011-09-01 10:21:52

jQuery Mobi元素

2009-07-15 13:41:00

JDBC實(shí)例

2009-12-17 09:09:48

Windows 7系統(tǒng)分區(qū)

2013-11-18 14:00:09

2022-06-09 07:07:35

服務(wù)GPUbatch

2009-04-22 08:49:30

Windows Mob微軟移動(dòng)OS

2022-10-08 00:06:00

JS運(yùn)行V8

2022-02-22 20:35:22

公鑰私鑰數(shù)據(jù)

2011-09-08 13:41:53

Widget

2009-07-22 17:15:04

C#實(shí)現(xiàn)

2012-11-20 09:33:02

2013-08-15 10:00:07

產(chǎn)品產(chǎn)品經(jīng)理優(yōu)秀的產(chǎn)品

2009-04-22 08:46:15

Windows Mob微軟移動(dòng)OS
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號