?
Solved

External TreeView using madRemote

Posted on 2003-03-17
8
Medium Priority
?
619 Views
Last Modified: 2010-04-04
Hi all,

I have followed another thread http://search.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20272830.html to its logical conclusion by madshi, and have realised this is where I am falling over.

I am trying to read the nodes of an external systreeview32, given an hWnd. I need the final code to work on all Win platforms, so would prefer to use madRemote to stop the lock to NT platforms only. Would like a code example similar to the one mentioned on the thread above, but which will examine an external process and return the text from the treeview, using madRemote.

External app is Kazaa, if that helps narrow it down... trying to read Upload/Download treeviews.

500 points available.

Javen
0
Comment
Question by:Javen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 20

Accepted Solution

by:
Madshi earned 2000 total points
ID: 8167182
This code only gives you the parent items, but it should be a good start to dig yourself into this stuff.

Regards, Madshi.


uses CommCtrl, madRemote;

procedure ReadTreeView(tv: dword);
var i1      : integer;
    ti      : TTvItem;
    pti     : PTvItem;
    pid, ph : dword;
    c1      : dword;
    arrCh   : array [0..MAX_PATH] of char;
begin
  GetWindowThreadProcessID(tv, pid);
  ph := OpenProcess(PROCESS_ALL_ACCESS, false, pid);
  if ph <> 0 then begin
    pti := AllocMemEx(sizeOf(ti) + MAX_PATH, ph);
    ZeroMemory(@ti, sizeOf(ti));
    dword(ti.pszText) := dword(pti) + MAX_PATH;
    ti.cchTextMax := MAX_PATH;
    ti.mask := TVIF_CHILDREN or TVIF_HANDLE or TVIF_IMAGE or TVIF_PARAM or
               TVIF_SELECTEDIMAGE or TVIF_STATE or TVIF_TEXT;
    ti.hItem := TreeView_GetFirstVisible(tv);
    for i1 := 0 to integer(TreeView_GetVisibleCount(tv)) - 1 do begin
      if WriteProcessMemory(ph, pti, @ti, sizeOf(ti), c1) and
         TreeView_GetItem(tv, pti^) and
         ReadProcessMemory(ph, pti, @ti, sizeOf(ti), c1) and
         ReadProcessMemory(ph, ti.pszText, @arrCh, MAX_PATH, c1) then
        MessageBox(0, arrCh, 'item found', 0);
      ti.hItem := TreeView_GetNextVisible(tv, ti.hItem);
    end;
    FreeMemEx(pti, ph);
    CloseHandle(ph);
  end;
end;
0
 

Author Comment

by:Javen
ID: 8186645
Hi madshi,

Once I have resolved my issues with using madRemote (cheers for your comments on the other thread), I shall test this out.

Hang on, and I'll get back to you soon...

Javen
0
 

Author Comment

by:Javen
ID: 8201506
Hi madShi/all,

In order to clarify, I am trying to get the information out of a Kazaa download/upload window. The code you have given above works, but no text is returned. I have used Spy++ to monitor the messages sent to the application, and this is what I've found...

1) GetNextItem returns hItem
2) GetItem returns the pointer to a TV_ITEM, which has the following...

mask: TVIF_PARAM
hItem : as obtained
state : TVIS_CUT | TVIS_EXPANDED | 77E16880
statemask : TVIS_OVERLAYMASK | TVIS_STATEIMAGEMASK | 009000A0
pszText : 0000110A
plus some other bits and bobs

I am guessing that the reason the string is not returning anything is because the treeview has multiple columns, and multiple text items in it.

If someone is able to help me more, I am willing to push the points up to 1000.

Cheers,

Javen
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 20

Expert Comment

by:Madshi
ID: 8201564
>> I am guessing that the reason the string is not returning anything is because the treeview has multiple columns, and multiple text items in it.

But does the first column not contain any text? You should get the text of the first column, if the code works correctly.

I don't have Kazaa installed (and I rather don't want to install it), so I can't really test it with that application. Perhaps you can try the code on some normal treeviews? Does it work on e.g. the Explorer's treeview?

Maybe Kazaa uses custom drawing, then we have a problem.
0
 

Author Comment

by:Javen
ID: 8201630
>> I don't have Kazaa installed (and I rather don't want to install it)

Don't blame you, at the moment, I am wishing I'd never heard of it either.

I am trying to test the code with another mini-app to get the data from Explorer.

Heres one question though...

I cut your code about to fit it into my program and replaced the "ph" with the process handle of the main window. Is this wrong? Does the treeview have a seperate process? This could be where I am going wrong.

Also, I am passing the tv : DWORD the handle of the treeview, is this correct?

Javen
0
 
LVL 20

Expert Comment

by:Madshi
ID: 8201658
"tv" is meant to be the handle of the treeview, that's correct. Why did you replace "ph"? My code gets the "ph" directly from the "tv" handle, so there should be no need to change it. Anyway, you *can* replace it, if you do it right. It should be the process handle which owns the tree view. And no, the tree views are not seperate processes.
0
 

Author Comment

by:Javen
ID: 8201725
Hi madShi,

Cheers for all that... I have managed to get the code working, and read the contents of an Explorer TreeView. I tried this with Kazaa, and I still get nothing.

The Kazaa treeview is very complex and has multiple columns, holding different textual values, and one which has a progressbar within it.

The possibility is that it does use Custom Drawing, which I know nothing about.

There is another thread, which you have participated in which covers hooking text out using madCodeHook. Could this be another way for me to go...

Cheers,

Javen
0
 
LVL 20

Expert Comment

by:Madshi
ID: 8201744
Hooking TextOut is an option, but that's really hard to do. Anyway, you can try. In that case please use the latest beta version:

http://madshi.bei.t-online.de/madCollectionBeta.exe
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question