[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.
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:
Private Sub Form_Load()
Dim x, y, z, m, g, k, o, b, ws
Set ws = CreateObject("wscript.shell")
Set x = GetObject("winmgmts:")
Set y = x.instancesof("Win32_Process")
For Each z In y
g = 0
k = z.getownersid
m = m & z.Description & " " & g & " " & k & " " & " " & vbCrLf
Next
MsgBox m, 64, "w32 Processes"
End Sub
cheers mate! :)
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...
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
Re: Retrieve items from TaskManager's listview
Where is the handle coming from and is it accurate?
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?
Re: Retrieve items from TaskManager's listview
de-u
Code:
hWnd = HexToDec("000D03E6")
how did you get this number 000D03E6 ?
Re: Retrieve items from TaskManager's listview
ooOos, how did i missed that robs question and the answer for that :confused:
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.
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...
Re: Retrieve items from TaskManager's listview
Re: Retrieve items from TaskManager's listview
Thanks! Will try it out later on... :thumb:
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?
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!
Re: [RESOLVED] Retrieve items from TaskManager's listview
Quote:
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.
?
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?