Come posso intercettare un'applicazione precedentemente aperta per chiuderla.
Grazie 1000
Come posso intercettare un'applicazione precedentemente aperta per chiuderla.
Grazie 1000
Per ottenere la lista dei programmi attivi (le caption):
Ti scrive il tutto in una ListBox.codice:Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long Const GW_HWNDFIRST = 0 Const GW_HWNDNEXT = 2 Dim CurrWnd As Long Dim Length As Long Dim TaskName As String Dim Parent As Long Sub LoadTaskList() List1.Clear CurrWnd = GetWindow(Form1.hwnd, GW_HWNDFIRST) While CurrWnd <> 0 Parent = GetParent(CurrWnd) Length = GetWindowTextLength(CurrWnd) TaskName = Space$(Length + 1) Length = GetWindowText(CurrWnd, TaskName, Length + 1) TaskName = Left$(TaskName, Len(TaskName) - 1) If Length > 0 Then If TaskName <> Me.Caption Then List1.AddItem TaskName End If CurrWnd = GetWindow(CurrWnd, GW_HWNDNEXT) DoEvents Wend End Sub Private Sub Form_Load() LoadTaskList End Sub
Quindi per chiuderla:
vai in questo messaggio
Ciao
Cerco ombrello vecchio, nuovo, moderno o antidiluviano; purché protegga da una pioggia che vien giù come Dio la manda. Fate presto che ho l’acqua alla gola. (Noè)
C# programming and other stuffs
Grazie 1000, ho messo una list nel form e cosi' ho tutta la lista delle applicazioni aperte, e se io adesso ne voglio chiudere una di queste che nel listbox e' identificata come 'MD progetto1'
Ciao e grazie
Scusami sono rinco....to non avevo letto bene la fine del msg.
GRAZIEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
Figurati. Ciao
Cerco ombrello vecchio, nuovo, moderno o antidiluviano; purché protegga da una pioggia che vien giù come Dio la manda. Fate presto che ho l’acqua alla gola. (Noè)
C# programming and other stuffs
come sempre....funziona a tutti ma a me no.......
facendo il debug ho visto ke addirittura mi entra in un loop quasi infinito......cioè....siccome l'inmfinito non esiste...direi tendente all'infinito..
non c'è un altro metodo???
please heeeeeeeelp meeeeeeeeee
E' vero l'infinito non esiste perché prima riavvii il pc!!! :gren:
Comunque sia il programma dovrebbe funzionare. Ti entra in loop probabilmente nel ciclo While CurrWnd <> 0...
Non te lo so spiegare però il motivo...
Ciao
Cerco ombrello vecchio, nuovo, moderno o antidiluviano; purché protegga da una pioggia che vien giù come Dio la manda. Fate presto che ho l’acqua alla gola. (Noè)
C# programming and other stuffs