Skip to content

Commit bbb2182

Browse files
authored
chore: add handle valid check
1 parent e24311c commit bbb2182

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

Plain Craft Launcher 2/Application.xaml.vb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,11 +201,10 @@ RetryCacheCheck:
201201
''' 从文件锁中尝试拖出进程
202202
''' </summary>
203203
Public Sub DropToTopByLock(LockPath As String)
204-
Dim Content = File.ReadAllBytes(LockPath)
205204
Dim Pid As Integer
206-
If Not Integer.TryParse(Encoding.UTF8.GetString(Content), Pid) Then Return
207-
ShowWindowToTop(Process.GetProcessById(Pid).MainWindowHandle)
208-
205+
If Not Integer.TryParse(File.ReadAllText(LockPath), Pid) Then Return
206+
Dim Handle = Process.GetProcessById(Pid)?.MainWindowHandle
207+
If Handle <> Intptr.Zero ShowWindowToTop(Handle)
209208
End Sub
210209

211210
'结束

0 commit comments

Comments
 (0)