Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to read the characters in the EditTable of SysListView32 style control ?

How to read the characters in the EditTable of SysListView32 style control ?

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    wangningyu
    wrote on last edited by
    #1

    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
    
    D R N 3 Replies Last reply
    0
    • W wangningyu

      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
      
      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      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 the Process32First()/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

      W 1 Reply Last reply
      0
      • D David Crow

        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 the Process32First()/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

        W Offline
        W Offline
        wangningyu
        wrote on last edited by
        #3

        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

        D 1 Reply Last reply
        0
        • W wangningyu

          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

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          Assuming you have the window handle of the control, first send it a LVM_GETITEMCOUNT message. Then for each item, send the control a LVM_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

          1 Reply Last reply
          0
          • W wangningyu

            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
            
            R Offline
            R Offline
            rand0941
            wrote on last edited by
            #5

            this item has two windows,you can find the editbox's handle to read text from it.

            1 Reply Last reply
            0
            • W wangningyu

              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
              
              N Offline
              N Offline
              nenfa
              wrote on last edited by
              #6

              do you have happen this problem: str1's content is equivalent to str2,str3,str4 and str5,how to solve the problem, thank you very much.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups