Newsgroup: it.comp.lang.visual-basic
Titolo: applicazione lanciata

C'è un modo per vedere se è stata lanciata o chiusa una qualsiasi
applicazione? Per esempio come posso veedere Winword.exe?
Grazie.

 applicazione? Per esempio come posso veedere Winword.exe?
Vedi sulla guida AppActivate e correlati


Salva la roba qua sotto in un file con estenzione frm, crea un progetto
ed aggiungicela.
E non mi chiedere nulla perché non so nulla.
####################
VERSION 5.00
Begin VB.Form makeList
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Form1"
   ClientHeight    =   2604
   ClientLeft      =   1860
   ClientTop       =   4212
   ClientWidth     =   4440
   BeginProperty Font
      Name            =   "Tahoma"
      Size            =   7.2
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   2604
   ScaleWidth      =   4440
   Begin VB.CommandButton Command1
      Caption         =   "leggi"
      Height          =   300
      Left            =   72
      TabIndex        =   3
      Top             =   36
      Width           =   1020
   End
   Begin VB.TextBox dmy
      Height          =   264
      Left            =   72
      TabIndex        =   2
      Top             =   396
      Width           =   4296
   End
   Begin VB.CheckBox Check1
      Caption         =   "auto"
      Height          =   300
      Left            =   1152
      Style           =   1  'Graphical
      TabIndex        =   1
      Top             =   36
      Width           =   1020
   End
   Begin VB.Timer Timer1
      Enabled         =   0   'False
      Interval        =   1000
      Left            =   2448
      Top             =   108
   End
   Begin VB.ListBox pELE
      Height          =   1812
      IntegralHeight  =   0   'False
      Left            =   72
      TabIndex        =   0
      Top             =   720
      Width           =   4296
   End
End
Attribute VB_Name = "makeList"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Const TH32CS_SNAPPROCESS As Long = 2&
Private Const MAX_PATH As Integer = 260
Private Type PROCESSENTRY32
    dwSize As Long
    cntUsage As Long
    th32ProcessID As Long
    th32DefaultHeapID As Long
    th32ModuleID As Long
    cntThreads As Long
    th32ParentProcessID As Long
    pcPriClassBase As Long
    dwFlags As Long
    szExeFile As String * MAX_PATH
End Type
Private Declare Function CreateToolhelpSnapshot Lib "kernel32" Alias
"CreateToolhelp32Snapshot" (ByVal lFlags As Long, ByVal lProcessID As
Long) As Long
Private Declare Function ProcessFirst Lib "kernel32" Alias
"Process32First" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32)
As Long
Private Declare Function ProcessNext Lib "kernel32" Alias
"Process32Next" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As
Long
Private Declare Sub CloseHandle Lib "kernel32" (ByVal hPass As Long)
Private Declare Function GetWindowText Lib "user32" Alias
"GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal
cch As Long) As Long
Private Declare Sub ExitProcess Lib "kernel32" (ByVal uExitCode As Long)
Private Declare Function GetExitCodeProcess Lib "kernel32" (ByVal
hProcess As Long, lpExitCode As Long) As Long
Private Declare Function GetCurrentProcess Lib "kernel32" () As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA"
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As
Any) As Long
Private Const WM_CLOSE = &H10
Const SWP_HIDEWINDOW = &H80
Const SWP_SHOWWINDOW = &H40
Const GW_CHILD = 5
Const GW_HWNDNEXT = 2
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long,
ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal
cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA"
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long,
ByVal wCmd As Long) As Long
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA"
(ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As
Long) As Long
Sub TrovaNuovo()
    Dim l As Integer, m As Integer
    Dim e As Boolean
    Dim tskN(200) As String, tskP As Integer
    tskP = 0
    Dim hSnapShot As Long
    Dim uProcess As PROCESSENTRY32
    Dim r As Long
    hSnapShot = CreateToolhelpSnapshot(TH32CS_SNAPPROCESS, 0&)
    If hSnapShot = 0 Then
        Exit Sub
    End If
    uProcess.dwSize = Len(uProcess)
    r = ProcessFirst(hSnapShot, uProcess)
    Do While r
        'l1.AddItem Format(uProcess.th32ProcessID)
        'l2.AddItem Format(uProcess.th32ModuleID)
        dmy = Trim(uProcess.szExeFile)
        tskN(tskP) = dmy
        'l3.AddItem uProcess.szExeFile
        r = ProcessNext(hSnapShot, uProcess)
        tskP = tskP + 1
    Loop
    Call CloseHandle(hSnapShot)
    If tskP > 0 Then
        For l = 0 To tskP
            e = False
            For m = 0 To pELE.ListCount - 1
                If InStr(pELE.List(m), tskN(l)) > 0 Then
                    e = True
                    Exit For
                End If
            Next m
            If e = False Then pELE.AddItem tskN(l)
        Next l
    End If
End Sub
Private Sub Check1_Click()
    TrovaNuovo
    If Check1.Value = 0 Then
        Timer1.Enabled = False
    Else
        Timer1.Enabled = True
    End If
End Sub
Private Sub Command1_Click()
    TrovaNuovo
End Sub
Private Sub Form_Load()
End Sub
Private Sub Timer1_Timer()
    TrovaNuovo
End Sub
####################
-> GbC
http://www.gbcweb.com

Vedi sulla guida AppActivate e correlati
Uhm, dubito che fosse quello che cercava.
Piuttosto dovrebbe fare un loop sui processi attivi:
HOWTO: List Running Processes
PSS ID Number: Q187913
Article Last Modified on 01-11-2001
-- 
hth, hal

strano...
mi aspettavo almeno un commento...
mi zarň zbagliato...
-> GbC
http://www.gbcweb.com

 ha scritto nel messaggio
news:al8v9.87439$%M1.22...@twister2.libero.it...


 [snip]
non mi riferivo a questo...
comunque prego...
-> GbC
http://www.gbcweb.com