Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Obtain data from an external Treeview

Posted on 2003-03-13
Medium Priority
Last Modified: 2010-08-05
Hi Guys,

First question... hope one of you can help! I am attemtping to retrieve data from a TreeView in an external process. I have successfully connected to the Handle of the Window the TreeView is in, and stepped down to have the handle of the TreeView itself.

I have also successfully retrieved the textual parts of a StatusBar, using VirtualAllocEx in the external process.

// Get process handle
GetWindowThreadProcessID(hMain, @idProcess);
hProcess := OpenProcess(PROCESS_ALL_ACCESS, False, idProcess);
if hProcess = 0 then RaiseLastWin32Error;

// Allocate buffer in process
pBuf := VirtualAllocEx(hProcess, nil, cBuf, MEM_COMMIT, PAGE_READWRITE);
if pBuf = nil then RaiseLastWin32Error;

//Get the Tree Handles
upTreehWnd := FindWindowEx(upstathwnd,0,'SysTreeView32',nil);
dnTreehWnd := FindWindowEx(dnstathwnd,0,'SysTreeView32',nil);
Form1.ListBox1.Items.Add('Up Tree = ' + inttostr(uptreehwnd) + ', Down Tree = ' + inttostr(dntreehWnd));

//Tree Counts
utrCount := treeview_getcount(uptreehwnd);
dtrCount := treeview_getcount(dntreehwnd);
form1.listbox1.Items.add('UpCount = ' + inttostr(utrCount) + ', DownCount = ' + inttostr(dtrCount));

//Try to get TreeItems
dnRt := treeview_getnextitem(dntreehwnd,0,TVGN_FIRSTVISIBLE);
dnRtN := treeview_getnextitem(dntreehwnd,dnrt, TVGN_NEXTVISIBLE);

//Create a TV_ITEM
dnRtItem.mask := TVIF_HANDLE and TVIF_TEXT;
dnRtItem.pszText := @s;
dnRtItem.cchTextMax := 1024;
dnRtItem.hItem := dnRT;

WHAT I need to do now I believe (from another subject http://www.experts-exchange.com/Programming/Programming_Platforms/Win_Prog/Q_20096218.html) is that I need to write the empty TV_ITEM using WriteProcessItem to the virtual memory in the other process, then call the TreeView_GetItem to populate that item, using the Memory of the other process, and then read it back into the local environment.

//Write the TV_ITEM to the Remote Process
rBln := WriteProcessMemory(hProcess, pointer(pTreeBuf), @pTreeBuf,sizeof(pTreeBuf), nil);

I believe that my problems are in the correct set-up of the local Pointers/Objects and their usage within the WriteProcessMemory function. However I may be wring... I've been using delphi for about 15 days so far...!

Ideally, an Expert will be able to provide me with details of how to set-up the TV_ITEM locally to receive information, how to write the blank TV_ITEM to the external process, how to retrieve the TV_ITEM back to the local process, and then perhaps help get access to the TV_ITEM textual content.

I am a total newbie at this, and I have no idea whether the number of points I have posted is acceptable or not. I'm hoping someone can help regardless.

Question by:Javen
  • 4
  • 3

Expert Comment

ID: 8130509

Author Comment

ID: 8145968
Hi Peter,

What does listening mean? Is this som3 sort of eXe jargon?

If the question does not have enought points attached, can someone just say so!



Expert Comment

ID: 8147135
It's just a way to say that i'm listening to this, and i want everybody else to know that i'm here :-)

If you raise the points you will probably get more attention - dont know for sure.
I think the question is to long. Maybe thats the problem.

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 8150303
Cheers Peter,

I followed the instructions of the eXe Question posting guide, but perhaps I went a bit overboard!

I will endeavour to raise the points...


Author Comment

ID: 8150321
Points increased...

Accepted Solution

PeterLarsen earned 1050 total points
ID: 8150378
Maybe you should post a question in the C++ topic area.
Don't post the entire question there - just the URL to this question and a few words.

Author Comment

ID: 8942029
This question is closed and dead... has been for ages, so I shall close it and award the points to PeterLarsen!

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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 Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…
Suggested Courses
Course of the Month13 days, 7 hours left to enroll

581 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