How to read the characters in the EditTable of SysListView32 style control ?
-
Hello everyone ! Here I want to read one of the ListCtrl datas from other process(report style),and write them into my ListCtrl. Example this code ,I want to read the "Window Task Manager" datas(in Process Tab),and write it into my ListCtrl:
BOOL CTestDlg::OnInitDialog()
{
CDialog::OnInitDialog();
......// TODO: Add extra initialization here // Set the ListCtrl style LONG lStyle = m\_ListCtrl.SendMessage(LVM\_GETEXTENDEDLISTVIEWSTYLE); lStyle |= LVS\_EX\_FULLROWSELECT | LVS\_EX\_GRIDLINES; m\_ListCtrl.SendMessage(LVM\_SETEXTENDEDLISTVIEWSTYLE, 0,(LPARAM)lStyle); // Add ListCtrl titles m\_ListCtrl.InsertColumn(0,"Name",NULL,100, -1); m\_ListCtrl.InsertColumn(1,"PID",NULL,60,-1); m\_ListCtrl.InsertColumn(2,"User",NULL,120,-1); m\_ListCtrl.InsertColumn(3,"CPU",NULL,60,-1); return TRUE; // return TRUE unless you set the focus to a control
}
void CTestDlg::OnBtnRead()
{
// TODO: Add your control notification handler code here
m_ListCtrl.DeleteAllItems();// Find window handle HWND hWnd,hListview; hWnd=::FindWindow(NULL,\_T("Windows Task Manager")); hWnd=::FindWindowEx(hWnd,0,"#32770",0); hListview=::FindWindowEx(hWnd,0,\_T("SysListView32"),NULL); if(!hListview) { MessageBox("Listview handle is NULL !"); return; } int count = (int)::SendMessage(hListview,LVM\_GETITEMCOUNT,0,0); int i,nItem; // Get the ListView lines. CString strTemp; strTemp.Format("Total process :%d",count); MessageBox(strTemp); CString str1=""; CString str2=""; CString str3=""; CString str4=""; DWORD pid; HANDLE process; LVITEM lvi, \*\_lvi; char firstitem\[512\], secitem\[512\],thirditem\[512\],fourthitem\[512\]; char \*\_firstitem, \*\_secitem,\*\_thirditem,\*\_fourthitem; memset(firstitem,0,512); memset(secitem,0,512); memset(thirditem,0,512); memset(fourthitem,0,512); // Get process pid. GetWindowThreadProcessId(hListview, &pid); process=OpenProcess(PROCESS\_VM\_OPERATION|PROCESS\_VM\_READ| PROCESS\_VM\_WRITE|PROCESS\_QUERY\_INFORMATION, FALSE, pid); \_lvi=(LVITEM\*)VirtualAllocEx(process, NULL, sizeof(LVITEM),MEM\_COMMIT, PAGE\_READWRITE); \_firstitem=(char\*)VirtualAllocEx(process, NULL, 512, MEM\_COMMIT,PAGE\_READWRITE); \_secitem =(char\*)VirtualAllocEx(process, NULL, 512, MEM\_COMMIT,PAGE\_READWRITE); \_thirditem=(char\*)VirtualAllocEx(process, NULL, 512, MEM\_COMMIT,PAGE\_READWRITE); \_fourthitem=(char\*)VirtualAllocEx(process,NULL, 512, MEM\_COMMIT,PAGE\_READWRITE); lvi.cchTextMax=512; // Here use degression , order with the t
-
Hello everyone ! Here I want to read one of the ListCtrl datas from other process(report style),and write them into my ListCtrl. Example this code ,I want to read the "Window Task Manager" datas(in Process Tab),and write it into my ListCtrl:
BOOL CTestDlg::OnInitDialog()
{
CDialog::OnInitDialog();
......// TODO: Add extra initialization here // Set the ListCtrl style LONG lStyle = m\_ListCtrl.SendMessage(LVM\_GETEXTENDEDLISTVIEWSTYLE); lStyle |= LVS\_EX\_FULLROWSELECT | LVS\_EX\_GRIDLINES; m\_ListCtrl.SendMessage(LVM\_SETEXTENDEDLISTVIEWSTYLE, 0,(LPARAM)lStyle); // Add ListCtrl titles m\_ListCtrl.InsertColumn(0,"Name",NULL,100, -1); m\_ListCtrl.InsertColumn(1,"PID",NULL,60,-1); m\_ListCtrl.InsertColumn(2,"User",NULL,120,-1); m\_ListCtrl.InsertColumn(3,"CPU",NULL,60,-1); return TRUE; // return TRUE unless you set the focus to a control
}
void CTestDlg::OnBtnRead()
{
// TODO: Add your control notification handler code here
m_ListCtrl.DeleteAllItems();// Find window handle HWND hWnd,hListview; hWnd=::FindWindow(NULL,\_T("Windows Task Manager")); hWnd=::FindWindowEx(hWnd,0,"#32770",0); hListview=::FindWindowEx(hWnd,0,\_T("SysListView32"),NULL); if(!hListview) { MessageBox("Listview handle is NULL !"); return; } int count = (int)::SendMessage(hListview,LVM\_GETITEMCOUNT,0,0); int i,nItem; // Get the ListView lines. CString strTemp; strTemp.Format("Total process :%d",count); MessageBox(strTemp); CString str1=""; CString str2=""; CString str3=""; CString str4=""; DWORD pid; HANDLE process; LVITEM lvi, \*\_lvi; char firstitem\[512\], secitem\[512\],thirditem\[512\],fourthitem\[512\]; char \*\_firstitem, \*\_secitem,\*\_thirditem,\*\_fourthitem; memset(firstitem,0,512); memset(secitem,0,512); memset(thirditem,0,512); memset(fourthitem,0,512); // Get process pid. GetWindowThreadProcessId(hListview, &pid); process=OpenProcess(PROCESS\_VM\_OPERATION|PROCESS\_VM\_READ| PROCESS\_VM\_WRITE|PROCESS\_QUERY\_INFORMATION, FALSE, pid); \_lvi=(LVITEM\*)VirtualAllocEx(process, NULL, sizeof(LVITEM),MEM\_COMMIT, PAGE\_READWRITE); \_firstitem=(char\*)VirtualAllocEx(process, NULL, 512, MEM\_COMMIT,PAGE\_READWRITE); \_secitem =(char\*)VirtualAllocEx(process, NULL, 512, MEM\_COMMIT,PAGE\_READWRITE); \_thirditem=(char\*)VirtualAllocEx(process, NULL, 512, MEM\_COMMIT,PAGE\_READWRITE); \_fourthitem=(char\*)VirtualAllocEx(process,NULL, 512, MEM\_COMMIT,PAGE\_READWRITE); lvi.cchTextMax=512; // Here use degression , order with the t
wangningyu wrote:
Example this code ,I want to read the "Window Task Manager" datas(in Process Tab),and write it into my ListCtrl:
Wouldn't it be easier to just get your own list via
CreateToolhelp32Snapshot()
and theProcess32First()
/Process32Next()
pair?"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
-
wangningyu wrote:
Example this code ,I want to read the "Window Task Manager" datas(in Process Tab),and write it into my ListCtrl:
Wouldn't it be easier to just get your own list via
CreateToolhelp32Snapshot()
and theProcess32First()
/Process32Next()
pair?"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
Sorry , I don't want the list of my processes. that's only a SysListView32 Style Control of the sample code. if the edit listcontrol in other programs, how can I read the list ?
modified on Thursday, October 22, 2009 12:42 PM
-
Sorry , I don't want the list of my processes. that's only a SysListView32 Style Control of the sample code. if the edit listcontrol in other programs, how can I read the list ?
modified on Thursday, October 22, 2009 12:42 PM
Assuming you have the window handle of the control, first send it a
LVM_GETITEMCOUNT
message. Then for each item, send the control aLVM_GETITEMTEXT
message."Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
-
Hello everyone ! Here I want to read one of the ListCtrl datas from other process(report style),and write them into my ListCtrl. Example this code ,I want to read the "Window Task Manager" datas(in Process Tab),and write it into my ListCtrl:
BOOL CTestDlg::OnInitDialog()
{
CDialog::OnInitDialog();
......// TODO: Add extra initialization here // Set the ListCtrl style LONG lStyle = m\_ListCtrl.SendMessage(LVM\_GETEXTENDEDLISTVIEWSTYLE); lStyle |= LVS\_EX\_FULLROWSELECT | LVS\_EX\_GRIDLINES; m\_ListCtrl.SendMessage(LVM\_SETEXTENDEDLISTVIEWSTYLE, 0,(LPARAM)lStyle); // Add ListCtrl titles m\_ListCtrl.InsertColumn(0,"Name",NULL,100, -1); m\_ListCtrl.InsertColumn(1,"PID",NULL,60,-1); m\_ListCtrl.InsertColumn(2,"User",NULL,120,-1); m\_ListCtrl.InsertColumn(3,"CPU",NULL,60,-1); return TRUE; // return TRUE unless you set the focus to a control
}
void CTestDlg::OnBtnRead()
{
// TODO: Add your control notification handler code here
m_ListCtrl.DeleteAllItems();// Find window handle HWND hWnd,hListview; hWnd=::FindWindow(NULL,\_T("Windows Task Manager")); hWnd=::FindWindowEx(hWnd,0,"#32770",0); hListview=::FindWindowEx(hWnd,0,\_T("SysListView32"),NULL); if(!hListview) { MessageBox("Listview handle is NULL !"); return; } int count = (int)::SendMessage(hListview,LVM\_GETITEMCOUNT,0,0); int i,nItem; // Get the ListView lines. CString strTemp; strTemp.Format("Total process :%d",count); MessageBox(strTemp); CString str1=""; CString str2=""; CString str3=""; CString str4=""; DWORD pid; HANDLE process; LVITEM lvi, \*\_lvi; char firstitem\[512\], secitem\[512\],thirditem\[512\],fourthitem\[512\]; char \*\_firstitem, \*\_secitem,\*\_thirditem,\*\_fourthitem; memset(firstitem,0,512); memset(secitem,0,512); memset(thirditem,0,512); memset(fourthitem,0,512); // Get process pid. GetWindowThreadProcessId(hListview, &pid); process=OpenProcess(PROCESS\_VM\_OPERATION|PROCESS\_VM\_READ| PROCESS\_VM\_WRITE|PROCESS\_QUERY\_INFORMATION, FALSE, pid); \_lvi=(LVITEM\*)VirtualAllocEx(process, NULL, sizeof(LVITEM),MEM\_COMMIT, PAGE\_READWRITE); \_firstitem=(char\*)VirtualAllocEx(process, NULL, 512, MEM\_COMMIT,PAGE\_READWRITE); \_secitem =(char\*)VirtualAllocEx(process, NULL, 512, MEM\_COMMIT,PAGE\_READWRITE); \_thirditem=(char\*)VirtualAllocEx(process, NULL, 512, MEM\_COMMIT,PAGE\_READWRITE); \_fourthitem=(char\*)VirtualAllocEx(process,NULL, 512, MEM\_COMMIT,PAGE\_READWRITE); lvi.cchTextMax=512; // Here use degression , order with the t
-
Hello everyone ! Here I want to read one of the ListCtrl datas from other process(report style),and write them into my ListCtrl. Example this code ,I want to read the "Window Task Manager" datas(in Process Tab),and write it into my ListCtrl:
BOOL CTestDlg::OnInitDialog()
{
CDialog::OnInitDialog();
......// TODO: Add extra initialization here // Set the ListCtrl style LONG lStyle = m\_ListCtrl.SendMessage(LVM\_GETEXTENDEDLISTVIEWSTYLE); lStyle |= LVS\_EX\_FULLROWSELECT | LVS\_EX\_GRIDLINES; m\_ListCtrl.SendMessage(LVM\_SETEXTENDEDLISTVIEWSTYLE, 0,(LPARAM)lStyle); // Add ListCtrl titles m\_ListCtrl.InsertColumn(0,"Name",NULL,100, -1); m\_ListCtrl.InsertColumn(1,"PID",NULL,60,-1); m\_ListCtrl.InsertColumn(2,"User",NULL,120,-1); m\_ListCtrl.InsertColumn(3,"CPU",NULL,60,-1); return TRUE; // return TRUE unless you set the focus to a control
}
void CTestDlg::OnBtnRead()
{
// TODO: Add your control notification handler code here
m_ListCtrl.DeleteAllItems();// Find window handle HWND hWnd,hListview; hWnd=::FindWindow(NULL,\_T("Windows Task Manager")); hWnd=::FindWindowEx(hWnd,0,"#32770",0); hListview=::FindWindowEx(hWnd,0,\_T("SysListView32"),NULL); if(!hListview) { MessageBox("Listview handle is NULL !"); return; } int count = (int)::SendMessage(hListview,LVM\_GETITEMCOUNT,0,0); int i,nItem; // Get the ListView lines. CString strTemp; strTemp.Format("Total process :%d",count); MessageBox(strTemp); CString str1=""; CString str2=""; CString str3=""; CString str4=""; DWORD pid; HANDLE process; LVITEM lvi, \*\_lvi; char firstitem\[512\], secitem\[512\],thirditem\[512\],fourthitem\[512\]; char \*\_firstitem, \*\_secitem,\*\_thirditem,\*\_fourthitem; memset(firstitem,0,512); memset(secitem,0,512); memset(thirditem,0,512); memset(fourthitem,0,512); // Get process pid. GetWindowThreadProcessId(hListview, &pid); process=OpenProcess(PROCESS\_VM\_OPERATION|PROCESS\_VM\_READ| PROCESS\_VM\_WRITE|PROCESS\_QUERY\_INFORMATION, FALSE, pid); \_lvi=(LVITEM\*)VirtualAllocEx(process, NULL, sizeof(LVITEM),MEM\_COMMIT, PAGE\_READWRITE); \_firstitem=(char\*)VirtualAllocEx(process, NULL, 512, MEM\_COMMIT,PAGE\_READWRITE); \_secitem =(char\*)VirtualAllocEx(process, NULL, 512, MEM\_COMMIT,PAGE\_READWRITE); \_thirditem=(char\*)VirtualAllocEx(process, NULL, 512, MEM\_COMMIT,PAGE\_READWRITE); \_fourthitem=(char\*)VirtualAllocEx(process,NULL, 512, MEM\_COMMIT,PAGE\_READWRITE); lvi.cchTextMax=512; // Here use degression , order with the t