Bir uygulamayı askıya almak vb.net

Durum
Üzgünüz bu konu cevaplar için kapatılmıştır...
Banlı Üye
Katılım
11 Tem 2017
Mesajlar
1,777
Çözümler
2
Tepki puanı
695
8 HİZMET YILI
Tamam, sadece kendim denedim. Aşağıdaki kod, terbiyeli olmaktan çok uzaktır (istisnasız kullanım, hiçbir SafeHandle ... gibi), sadece basit fikirleri göstermek için basit ve açık yapmak istiyorum.

Not defteri ve medya oynatıcıda (MP3 çalarken) denedim. Not defteri kooperatif olmak için basit ama wmplayer bazı garip davranışlar var (çok şaşırtıcı değil).

İyi eğlenceler:
Visual Basic:
 <Flags()> _
    Public Enum ThreadAccess As Integer
        TERMINATE = (&H1)
        SUSPEND_RESUME = (&H2)
        GET_CONTEXT = (&H8)
        SET_CONTEXT = (&H10)
        SET_INFORMATION = (&H20)
        QUERY_INFORMATION = (&H40)
        SET_THREAD_TOKEN = (&H80)
        IMPERSONATE = (&H100)
        DIRECT_IMPERSONATION = (&H200)
    End Enum

    Private Declare Function OpenThread Lib "kernel32.dll" (ByVal dwDesiredAccess As ThreadAccess, ByVal bInheritHandle As Boolean, ByVal dwThreadId As UInteger) As IntPtr
    Private Declare Function SuspendThread Lib "kernel32.dll" (ByVal hThread As IntPtr) As UInteger
    Private Declare Function ResumeThread Lib "kernel32.dll" (ByVal hThread As IntPtr) As UInteger
    Private Declare Function CloseHandle Lib "kernel32.dll" (ByVal hHandle As IntPtr) As Boolean

    Private Sub SuspendProcess(ByVal process As System.Diagnostics.Process)
        For Each t As ProcessThread In process.Threads
            Dim th As IntPtr

            th = OpenThread(ThreadAccess.SUSPEND_RESUME, False, t.Id)
            If th <> IntPtr.Zero Then
                SuspendThread(th)
                CloseHandle(th)
            End If
        Next
    End Sub

    Private Sub ResumeProcess(ByVal process As System.Diagnostics.Process)
        For Each t As ProcessThread In process.Threads
            Dim th As IntPtr

            th = OpenThread(ThreadAccess.SUSPEND_RESUME, False, t.Id)
            If th <> IntPtr.Zero Then
                ResumeThread(th)
                CloseHandle(th)
            End If
        Next
    End Sub
System.Diagnostics ad alanındaki Process sınıfını kullanın.

Çalışan uygulamayı durdurmanız gerekiyorsa aşağıdaki kodu kullanın.
VB.Net:
 Dim p() As Process = Process.GetProcessesByName("ProcessName") 
        If p.Count > 0 Then
            p(0).Kill() 
        End If
Uygulamayı başlatmak için Process.Start Yöntemini kullanın.
İyi Kulanımlar :)
 
Son düzenleme:
Seçkin Üye
Katılım
8 Ağu 2017
Mesajlar
545
Tepki puanı
129
Ödüller
7
Yaş
32
8 HİZMET YILI
Çeviriden Çevirip mi Yazdın Kardeş Anlamak İçin 5 kere tekrar Ettim hala anlamadım.
 
Durum
Üzgünüz bu konu cevaplar için kapatılmıştır...
Üst