簡體   English   中英

VB.NET使用ProcessName

[英]VB.NET using ProcessName

我創建了一個程序,該程序具有按進程名稱讀取應用程序的功能...

運行Calc.exe時,Label31從CLOSE更改為OPEN,但是當我關閉Calc.exe Label31時,不想從OPEN更改回CLOSE...。

我的密碼

Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
Dim myProcess() As Process = System.Diagnostics.Process.GetProcessesByName("calc")
    For Each Read As Process In myProcess
        Label31.Text = "OPEN"
    Next
End Sub

有人可以幫我計算關閉的label31從OPEN變為CLOSE時的計算方式嗎?

如果您要進行輪詢,則只需執行以下操作:

Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
    Dim myProcess() As Process = System.Diagnostics.Process.GetProcessesByName("calc")
    Label31.Text = If(myProcess.Length > 0, "OPEN", "CLOSED")
End Sub

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM