Visualizzazione dei risultati da 1 a 4 su 4
  1. #1
    Utente di HTML.it L'avatar di luisa227
    Registrato dal
    Mar 2002
    Messaggi
    2,305

    Vb6 - Recuperare I Nomi Delle Applicazioni Elencate Nel Task Manager

    Principiante --È possibile recuperare i nomi delle applicazioni (non dei processi) elencate nel task manager?
    Ho fatto una ricerca ma non ho trovato nulla…ho anche provato con le API ma nulla…
    Che api devo usare?
    Praticamente vorrei creare una seconda specie di task manager con l’elenco delle applicazioni che ho già aperto o che sto aprendo. Help!
    Le mie richieste qui sul forum sono al 99,9% considerate assurde e senza senso, ma per me un senso lo hanno e gradirei una risposta più seria possibile. Grazie

  2. #2
    Utente di HTML.it L'avatar di luisa227
    Registrato dal
    Mar 2002
    Messaggi
    2,305
    up
    Le mie richieste qui sul forum sono al 99,9% considerate assurde e senza senso, ma per me un senso lo hanno e gradirei una risposta più seria possibile. Grazie

  3. #3
    Utente di HTML.it L'avatar di junx
    Registrato dal
    May 2004
    Messaggi
    322
    Crea un nuovo progetto, aggiungi 3 CommandButton e chiamali:

    cmdSwitch, cmdRefresh e cmdExit

    Aggiungi pure un controllo ListBox e chiamalo lstApp

    copia, incolla e prova:

    codice:
    Const WS_MINIMIZE = &H20000000
    Const HWND_TOP = 0
    Const SWP_NOSIZE = &H1
    Const SWP_NOMOVE = &H2
    Const SWP_SHOWWINDOW = &H40
    Const GW_HWNDFIRST = 0
    Const GW_HWNDNEXT = 2
    Const GWL_STYLE = (-16)
    Const SW_RESTORE = 9
    Dim IsTask As Long
    
    
    Const WS_VISIBLE = &H10000000
    Const WS_BORDER = &H800000
    
    Const WS_CLIPSIBLINGS = &H4000000
    Const WS_THICKFRAME = &H40000
    Const WS_GROUP = &H20000
    Const WS_TABSTOP = &H10000
    
    
    Private Declare Function ShowWindow Lib "User32" _
        (ByVal hWnd As Long, ByVal flgs As Long) As Long
    Private Declare Function GetWindow Lib "User32" _
        (ByVal hWnd As Long, ByVal wCmd As Long) As Long
    Private Declare Function GetWindowWord Lib "User32" _
        (ByVal hWnd As Long, ByVal wIndx As Long) As Long
    Private Declare Function GetWindowLong Lib "User32" Alias "GetWindowLongA" _
        (ByVal hWnd As Long, ByVal wIndx As Long) As Long
    Private Declare Function GetWindowText Lib "User32" Alias "GetWindowTextA" _
        (ByVal hWnd As Long, ByVal lpSting As String, ByVal nMaxCount As Long) As Long
    Private Declare Function GetWindowTextLength Lib "User32" Alias "GetWindowTextLengthA" _
        (ByVal hWnd As Long) As Long
    Private Declare Function SetWindowPos Lib "User32" (ByVal hWnd As Long, _
        ByVal insaft As Long, ByVal x%, ByVal y%, ByVal cx%, ByVal cy%, _
        ByVal flgs As Long) As Long
    Private Declare Function GetModuleFileName Lib "kernel32" Alias _
        "GetModuleFileNameA" (ByVal hModule As Long, ByVal lpFileName _
        As String, ByVal nSize As Long) As Long
    
    
    
    
    Sub cmdExit_Click()
    Unload Me
    Set Activate = Nothing
    End Sub
    
    Sub cmdRefresh_Click()
    FindAllApps
    End Sub
    
    Sub cmdSwitch_Click()
    Dim hWnd As Long
    Dim x As Long
    Dim lngWW As Long
    If lstApp.ListIndex < 0 Then Beep: Exit Sub
    
    hWnd = lstApp.ItemData(lstApp.ListIndex)
    
    lngWW = GetWindowLong(hWnd, GWL_STYLE)
    
    If lngWW And WS_MINIMIZE Then
        x = ShowWindow(hWnd, SW_RESTORE)
    End If
    
    x = SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, _
        SWP_NOMOVE Or SWP_NOSIZE Or SWP_SHOWWINDOW)
    End Sub
    
    Sub FindAllApps()
    Dim hwCurr As Long
    Dim intLen As Long
    Dim strTitle As String
    Dim NomeFile As String
    Dim lung As Long
    Dim prova As String
    
    
    lstApp.Clear
    hwCurr = GetWindow(Me.hWnd, GW_HWNDFIRST)
    Do While hwCurr
      If hwCurr <> Me.hWnd And TaskWindow(hwCurr) Then
        intLen = GetWindowTextLength(hwCurr) + 1
        strTitle = Space$(intLen)
        intLen = GetWindowText(hwCurr, strTitle, intLen)
        lung = GetModuleFileName(hwCurr, NomeFile, 100)
        prova = NomeFile
        If intLen > 0 Then
          lstApp.AddItem strTitle & lung
    
          lstApp.ItemData(lstApp.NewIndex) = hwCurr
        End If
      End If
      hwCurr = GetWindow(hwCurr, GW_HWNDNEXT)
    Loop
    End Sub
    
    Sub Form_Load()
    IsTask = WS_VISIBLE Or WS_BORDER
    FindAllApps
    End Sub
    
    Sub Form_Paint()
    FindAllApps
    End Sub
    
    Sub lstApp_DblClick()
    cmdSwitch.Value = True
    End Sub
    
    Function TaskWindow(hwCurr As Long) As Long
    Dim lngStyle As Long
    lngStyle = GetWindowLong(hwCurr, GWL_STYLE)
    If (lngStyle And IsTask) = IsTask Then TaskWindow = True
    End Function


    fammi un fischio se non funziona.

  4. #4
    Utente di HTML.it L'avatar di luisa227
    Registrato dal
    Mar 2002
    Messaggi
    2,305
    Come faccio a sapere l’ora in cui avvio ad esempio outlook? Il codice va bene ma ogni volta che apro una finestra mi rifà giustamente il ciclo, e quindi l’aggiornamento…come faccio a farmi dare solo l’ultima applicazione che ho aperto? E l’ora di apertura?
    Le mie richieste qui sul forum sono al 99,9% considerate assurde e senza senso, ma per me un senso lo hanno e gradirei una risposta più seria possibile. Grazie

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.