HOW TO:重启程序(WinForm)

Author:水如烟  

Public   Class  RestartProgramService

    
Private   Shared  gAppLocation  As   String

    
Public   Shared   Sub  Run()
        
AddHandler  AppDomain.CurrentDomain.ProcessExit,  AddressOf  AppDomain_ProcessExit
        gAppLocation 
=  Reflection.Assembly.GetEntryAssembly.Location
        System.Diagnostics.Process.GetCurrentProcess.CloseMainWindow()
    
End Sub

    
Private   Shared   Sub  AppDomain_ProcessExit( ByVal  sender  As   Object ByVal  e  As  System.EventArgs)
        System.Diagnostics.Process.Start(gAppLocation)
    
End Sub

End Class

可怜,我居然不知道已有Application.Restart这玩意儿.

你可能感兴趣的:(WinForm)