Loading ...
Sorry, an error occurred while loading the content.

Re: Retrieving ListView text (Is this SysListView32?)

Expand Messages
  • Dennis K. Paulsen
    Sorry, I m not aware of a readily available version of Win32::GuiTest that includes this functionality. One thing to note about this functionality is that
    Message 1 of 4 , May 14 5:43 PM
    • 0 Attachment
      Sorry, I'm not aware of a readily available version of
      Win32::GuiTest that includes this functionality. One thing to note
      about this functionality is that since it uses VirtualAllocEx it
      will most definetly not function under Windows 95,98, or ME.

      However, according to the thread below, it looks like Paul C. may
      have wrote this. You could reply to Paul (in msg #81) and ask him
      if he can send you a build of Win32::GuiTest with this functionality.

      Regards,
      Dennis K. Paulsen

      --- In perlguitest@yahoogroups.com, "gkupps" <gkupps@y...> wrote:
      > Is there a Win32::GuiTest with this functionality built in?
      > --- In perlguitest@yahoogroups.com, "Garnet R. Chaney"
      <gchaney@w...>
      > wrote:
      > > Is this the code that would deal with a 'SysListView32' class
      object?
      > >
      > > Did this find it's way into the 1.49.2 build? If not, could
      you
      > > please provide me a binary distribution (PPD) that includes
      this? I
      > > am still not sure how to build these perl modules that require
      the
      > > use of a C compiler under Windows, but even worse, I don't have
      a C
      > > compiler on the machine where I am using this.
      > >
      > > - Garnet
      > >
      > > --- In perlguitest@yahoogroups.com, "paulbt2000"
      <pcovington@a...>
      > > wrote:
      > > > Here is some code that will retrieve the text from a ListView
      box.
      > > >
      > > > Paul
      > > >
      > > > SV*
      > > > GetListViewHelper(HWND hwnd, int index)
      > > > {
      > > > /* some code adapted from Jeffrey Richter's September 1997
      > > > Q&A article in the Microsoft Systems Journal */
      > > >
      > > > SV* sv = 0;
      > > > HANDLE hProcess;
      > > > LV_ITEM* plvi;
      > > > char newlvi[255];
      > > > int nIndex = 0;
      > > > LV_ITEM lvi;
      > > >
      > > >
      > > > /* Get the count of items in the ListView control */
      > > > int nCount = ListView_GetItemCount(hwnd);
      > > >
      > > > /* Open a handle to the remote process's kernel object */
      > > > DWORD dwProcessId;
      > > > GetWindowThreadProcessId(hwnd, &dwProcessId);
      > > > hProcess = OpenProcess( PROCESS_VM_OPERATION |
      > > > PROCESS_VM_READ | PROCESS_VM_WRITE, FALSE, dwProcessId);
      > > >
      > > > if (hProcess == NULL) {
      > > > printf("Could not communicate with process");
      > > > }
      > > >
      > > > /* Allocate memory in the remote process's address space */
      > > > plvi = (LV_ITEM*) VirtualAllocEx(hProcess, NULL, 4096,
      > > > MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
      > > >
      > > > newlvi[0] = '\0';
      > > >
      > > > /* Initialize a local LV_ITEM structure */
      > > > lvi.mask = LVIF_TEXT;
      > > > lvi.iItem = index;
      > > > lvi.iSubItem = 0;
      > > > /* NOTE: The text data immediately follows the LV_ITEM
      > > > structure
      > > > in the memory block allocated in the remote
      > > > process.*/
      > > > lvi.pszText = (LPTSTR) (plvi + 1);
      > > > lvi.cchTextMax = 100;
      > > >
      > > > /* Write the local LV_ITEM structure to the remote memory
      > > > block */
      > > > WriteProcessMemory(hProcess, plvi, &lvi, sizeof(lvi), NULL);
      > > >
      > > > /* Tell the ListView control to fill the remote LV_ITEM
      > > > structure */
      > > > ListView_GetItem(hwnd, plvi);
      > > >
      > > > /* Read the remote text string into the end of our buffer */
      > > > ReadProcessMemory(hProcess, plvi+1, &newlvi, 255, NULL);
      > > >
      > > > /*printf("%s\n", newlvi);*/
      > > >
      > > > if (newlvi != 0) {
      > > > sv = newSVpv(newlvi, strlen(newlvi));
      > > > }
      > > >
      > > > /* Free the memory in the remote process's address space */
      > > > VirtualFreeEx(hProcess, plvi, 0, MEM_RELEASE);
      > > >
      > > > CloseHandle(hProcess);
      > > >
      > > > return sv;
      > > > }
      > > >
      > > >
      > > >
      > > > void
      > > > GetListViewContents(hwnd)
      > > > HWND hwnd;
      > > > PPCODE:
      > > > int nelems = ListView_GetItemCount(hwnd);
      > > > int i;
      > > > for (i = 0; i < nelems; i++) {
      > > > XPUSHs(sv_2mortal(GetListViewHelper(hwnd, i)));
      > > > }
      > > >
      > > >
      > > > SV*
      > > > GetListViewText(hwnd, index)
      > > > HWND hwnd;
      > > > int index
      > > > CODE:
      > > > RETVAL = GetListViewHelper(hwnd, index);
      > > > OUTPUT:
      > > > RETVAL
    Your message has been successfully submitted and would be delivered to recipients shortly.