我正在尝试制作一个可以打开和关闭 bluestacks 应用程序的程序。关闭意味着完全退出应用程序。因为即使您退出 bluestacks 应用程序,该过程也将重新启动。我试图杀死的进程是:
- “HD-BlockDevice.exe”
- “HD-Agent.exe”
- “HD-LogRotatorService.exe”
- “HD-UpdaterService.exe”
当我手动杀死第一个进程时,除了 2~3 个进程之外,其他进程将关闭。每次关闭应用程序时杀死四个进程有点痛苦,所以我正在创建这个。这是我的代码
Public Class Form1
Dim p() As Process
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer_ProcessCheck.Start()
End Sub
Private Sub Timer_ProcessCheck_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer_ProcessCheck.Tick
p = Process.GetProcessesByName("HD-BlockDevice.exe")
If p.Count > 0 Then
' Process is running
'Button_Close.Enabled = True
Else
' Process is not running
'Button_Close.Enabled = False
End If
End Sub
Private Sub Button_Open_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_Open.Click
Process.Start("C:\Program Files (x86)\BlueStacks\HD-StartLauncher.exe")
End Sub
Private Sub Button_Close_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_Close.Click
'p = Process.GetProcessesByName("HD-BlockDevice.exe")
'p.kill()
'p.close()
'While p.Length > 0
'For i As Integer = p.Length - 1 To 0 Step -1
'p(i).CloseMainWindow()
'Next
'p = Process.GetProcessesByName("HD-BlockDevice.exe")
'End While
'Timer_ProcessKill.Start()
End Sub
Private Sub Timer_ProcessKill_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer_ProcessKill.Tick
For Each prog As Process In Process.GetProcesses
If prog.ProcessName = "HD-BlockDevice.exe" Then
prog.Kill()
End If
Next
End Sub
End Class
我的问题是:
- 我的流程检查器不起作用(当流程已经存在时,它不会启用关闭按钮)
- 我查找的任何进程终止都不起作用(这些都是我在代码中所做的评论)