Results 1 to 16 of 16

Thread: [RESOLVED] Retrieve items from TaskManager's listview

  1. #1

    Thread Starter
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Resolved [RESOLVED] Retrieve items from TaskManager's listview

    I was actually testing a code on my own but it was bombing and I left it at work. Perhaps you guys could pinpoint me to a clearer path. I was using some API and a LV_Item type but it was crashing leaving me clueless. I will try to post the code when I get to work.
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  2. #2
    Member
    Join Date
    Jul 2008
    Posts
    40

    Re: Retrieve items from TaskManager's listview

    hi,
    i use this to see all my processes when my task manager is busted by some
    virus.it was originally made in vbscript, but it works in vb6 too.
    vb Code:
    1. Private Sub Form_Load()
    2. Dim x, y, z, m, g, k, o, b, ws
    3. Set ws = CreateObject("wscript.shell")
    4. Set x = GetObject("winmgmts:")
    5. Set y = x.instancesof("Win32_Process")
    6. For Each z In y
    7. g = 0
    8. k = z.getownersid
    9.  
    10. m = m & z.Description & "       " & g & "       " & k & "     " &  "    " & vbCrLf
    11.  
    12. Next
    13. MsgBox m, 64, "w32 Processes"
    14. End Sub
    cheers mate!

  3. #3

    Thread Starter
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Retrieve items from TaskManager's listview

    Well, I could easily list the processes but I what I really want is to retrieve the items from the TaskManager's listview for another purpose...
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  4. #4

    Thread Starter
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Retrieve items from TaskManager's listview

    This is my attempt, it is failing on the boldened line, can anyone pinpoint what I am doing wrong?

    Code:
    Option Explicit
    
    Private Enum LVITEM_state
      LVIS_FOCUSED = &H1
      LVIS_SELECTED = &H2
      LVIS_CUT = &H4
      LVIS_DROPHILITED = &H8
      LVIS_ACTIVATING = &H20
      LVIS_OVERLAYMASK = &HF00
      LVIS_STATEIMAGEMASK = &HF000
    End Enum
    
    Private Enum LVITEM_mask
      LVIF_TEXT = &H1
      LVIF_IMAGE = &H2
      LVIF_PARAM = &H4
      LVIF_STATE = &H8
    #If (WIN32_IE >= &H300) Then
      LVIF_INDENT = &H10
      LVIF_NORECOMPUTE = &H800
    #End If
      LVIF_DI_SETITEM = &H1000   ' NMLVDISPINFO notification
    End Enum
    
    Private Type LVITEM   ' was LV_ITEM
        mask As Long
        iItem As Long
        iSubitem As Long
        state As Long
        stateMask As Long
        pszText As String
        cchTextMax As Long
        iImage As Long
        lParam As Long
        iIndent As Long
    End Type
    
    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
                                (ByVal hWnd As Long, _
                                ByVal wMsg As Long, _
                                ByVal wParam As Long, _
                                lParam As Any) As Long
                                
    Private Const LVM_FIRST = &H1000
    Private Const LVM_GETITEMCOUNT = (LVM_FIRST + 4)
    Private Const LVM_GETITEM = (LVM_FIRST + 5)
    
    Function HexToDec(HexValue As String) As Long
        HexToDec = Val("&H" & HexValue)
    End Function
    
    Private Sub Command1_Click()
        Dim a       As Long
        Dim b       As Long
        Dim hWnd    As Long
        Dim lvi     As LVITEM
        
        hWnd = HexToDec("000D03E6")
        b = ListView_GetItemCount(hWnd)
        b = b - 1
        For a = 0 To b
            lvi.mask = LVIF_TEXT
            lvi.iItem = a
            ListView_GetItem hWnd, lvi
            Debug.Print lvi.pszText
        Next
        MsgBox "Done"
    End Sub
    
    Public Function ListView_GetItemCount(hWnd As Long) As Long
        ListView_GetItemCount = SendMessage(hWnd, LVM_GETITEMCOUNT, 0, 0)
    End Function
     
    Private Function ListView_GetItem(hWnd As Long, pitem As LVITEM) As Boolean
        ListView_GetItem = SendMessage(hWnd, LVM_GETITEM, 0, pitem)
    End Function
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  5. #5
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Retrieve items from TaskManager's listview

    Where is the handle coming from and is it accurate?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  6. #6

    Thread Starter
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Retrieve items from TaskManager's listview

    Yes it is accurate, I am getting it by using Spy++. I could get the item count by "b = ListView_GetItemCount(hWnd)" so the handle is correct. Got any hints there gangsta?
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  7. #7
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: Retrieve items from TaskManager's listview

    de-u
    Code:
        hWnd = HexToDec("000D03E6")
    how did you get this number 000D03E6 ?

  8. #8
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: Retrieve items from TaskManager's listview

    ooOos, how did i missed that robs question and the answer for that

  9. #9
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Retrieve items from TaskManager's listview

    Seems the task manager may be protected from messages as everytime I try to read it it will crash the task manager but if I read any other listview, like Explorer, it doesnt crash.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  10. #10

    Thread Starter
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Retrieve items from TaskManager's listview

    Yes, that is what happening when I am trying also. I am hoping there is a workaround to this...
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  11. #11
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    Re: Retrieve items from TaskManager's listview

    Removed
    Last edited by Edgemeal; Mar 5th, 2009 at 01:12 PM.

  12. #12

    Thread Starter
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Retrieve items from TaskManager's listview

    Thanks! Will try it out later on...
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  13. #13
    Addicted Member
    Join Date
    Feb 2009
    Posts
    156

    Re: [RESOLVED] Retrieve items from TaskManager's listview

    Code:
       
    Module1.bas (9.5 KB, 17 views)
    i use this code and return is valid but after 10-15 minute return is 0
    (that hwnd is ok and that program have a item in listview)
    why?

  14. #14
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    Re: [RESOLVED] Retrieve items from TaskManager's listview

    Quote Originally Posted by kakablack
    Code:
       
    Module1.bas (9.5 KB, 17 views)
    i use this code and return is valid but after 10-15 minute return is 0
    (that hwnd is ok and that program have a item in listview)
    why?
    I go that module from another forum a long time ago and never really had a use for it so can't say what the problem may be.

    But ya there seems to be a problem with it if you keep calling it, I just tried calling it in a loop (from a timer set to 1sec) pointed to task managers listview and eventually all it returned was the Handle, the col and row counts, but no item data.

    I'll delete that file it must be buggy! SORRY!

  15. #15
    Addicted Member
    Join Date
    Feb 2009
    Posts
    156

    Re: [RESOLVED] Retrieve items from TaskManager's listview

    I go that module from another forum a long time ago and never really had a use for it so can't say what the problem may be.

    But ya there seems to be a problem with it if you keep calling it, I just tried calling it in a loop (from a timer set to 1sec) pointed to task managers listview and eventually all it returned was the Handle, the col and row counts, but no item data.

    I'll delete that file it must be buggy! SORRY!
    now what can i do for it?
    i used this module.
    ?

  16. #16
    Addicted Member
    Join Date
    Feb 2009
    Posts
    156

    Re: [RESOLVED] Retrieve items from TaskManager's listview

    Code:
    VirtualFreeEx hProc, ByVal lxprocLVITEM, LenB(LVITEM), MEM_RELEASE
    CloseHandle hProc
    whats this?
    maybe it can RESOLVE my problem?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width