-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathApplication.xaml.vb
More file actions
88 lines (79 loc) · 3.69 KB
/
Application.xaml.vb
File metadata and controls
88 lines (79 loc) · 3.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
Imports System.Windows.Threading
Imports System.Diagnostics
Imports System.Security.Principal
Imports System.Reflection
Class Application
' 应用程序级事件(例如 Startup、Exit 和 DispatcherUnhandledException)
' 可以在此文件中进行处理。
Protected Overrides Sub OnStartup(ByVal e As StartupEventArgs)
AddHandler AppDomain.CurrentDomain.UnhandledException, AddressOf CurrentDomain_UnhandledException
AddHandler DispatcherUnhandledException, AddressOf Application_DispatcherUnhandledException
MyBase.OnStartup(e)
End Sub
Public ztpd As Boolean = True
Private Sub CurrentDomain_UnhandledException(ByVal sender As Object, ByVal e As UnhandledExceptionEventArgs)
If ztpd = True Then
ztpd = False
error1 = "SeewoStart 4.0 已不能正常运行,请截图并反馈"
error2 = e.ExceptionObject.ToString()
Dim error114 As New error114
error114.Show()
End If
End Sub
Private Sub Application_Startup(sender As Object, e As StartupEventArgs) Handles Me.Startup
Dim exePath As String = System.Reflection.Assembly.GetExecutingAssembly().Location
Dim exeFileName As String = System.IO.Path.GetFileNameWithoutExtension(exePath)
If e.Args.Length > 0 Then
'MsgBox(e.Args(0).ToString)
If e.Args(0) = "/settings" Then
Dim isAdmin As Boolean = New WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator)
If Not isAdmin Then
Dim startInfo As New ProcessStartInfo(AppDomain.CurrentDomain.BaseDirectory & exeFileName)
startInfo.Verb = "runas"
startInfo.Arguments = e.Args(0)
Process.Start(startInfo)
Process.GetCurrentProcess.Kill()
End If
SharedV.StartWindow = "1"
Dim settingsWindow As New Window1()
settingsWindow.Show()
Else
If e.Args(0) = "/Emergency-mode" Then
Dim isAdmin As Boolean = New WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator)
If Not isAdmin Then
Dim startInfo As New ProcessStartInfo(AppDomain.CurrentDomain.BaseDirectory & exeFileName)
startInfo.Verb = "runas"
startInfo.Arguments = e.Args(0)
Process.Start(startInfo)
Process.GetCurrentProcess.Kill()
End If
SharedV.StartWindow = "1"
Dim jy As New Emergency_mode
jy.Show()
Else
SharedV.StartString = e.Args(0)
End If
End If
'Else
' Dim mainWindow As New MainWindow()
' mainWindow.Show()
End If
'SharedV.StartWindow = "1"
'Dim settingsWindow As New Window1()
'settingsWindow.Show()
End Sub
Private Sub Application_Exit(sender As Object, e As ExitEventArgs) Handles Me.[Exit]
GC.Collect()
GC.WaitForPendingFinalizers()
End Sub
Private Sub Application_DispatcherUnhandledException(sender As Object, e As Windows.Threading.DispatcherUnhandledExceptionEventArgs) Handles Me.DispatcherUnhandledException
If ztpd = True Then
ztpd = False
error1 = "SeewoStart 4.0 已不能正常运行,请截图并反馈"
error2 = e.Exception.ToString()
Dim error114 As New error114
error114.Show()
e.Handled = True
End If
End Sub
End Class