防止同一个程序多次运行

来源:互联网 发布:西安未央网络花店 编辑:程序博客网 时间:2024/06/09 15:51
 Function   IsSingleInstance()   As   Boolean  
   
                  If   UBound(Diagnostics.Process.GetProcessesByName(   _  
                    Diagnostics.Process.GetCurrentProcess.ProcessName))   >   0   Then  
                          Return   False  
                  Else  
                          Return   True  
                  End   If  
   
          End   Function  
   
  调用:  
                          If   IsSingleInstance()   =   False   Then  
                                  msgbox   "二重起動"  
                                  Application.Exit()  
                                  Exit   Sub  
                          End   If 
原创粉丝点击