CListCtrl->GetItem() across processes

Posted on 1998-12-03
Last Modified: 2013-11-20
I need to get the text from a multi column listview in an Application I dont have src code for.
I can get a handle to the listview, attach a listctrl and do things like get an itemcount, and call deleteItem.

The problem comes when I try to call GetItem or GetItemText.
I've been told its because passing memory pointers across processes is not straight forward.

Fine, But can it be done. I have src for the program getting the information, not for the program the listctrl is in.

Has any one done this, or seen a solution for it ?

thanks ,

Question by:ianwhite
  • 3
LVL 15

Expert Comment

by:Tommy Hui
ID: 1325711
Using the common controls across processes do not work. In order to retrieve information about a common control across process boundaries, it is necessary to write a DLL that can be injected into the target process space. Usually, writing a system hook will do the job the quickest. Then you need to write a process that communicates with the DLL to get the DLL to do that thing you need, but in the context of the target process. The DLL has to then write the information into a memory map so that another process can access it.

What you're trying to do is not trivial and that is why the solution is that much harder.

Author Comment

ID: 1325712
Ok thanks so far, but I'm still a little confused.
Does that mean I need to enable the process the owns the list box to load the dll, or is it possible to force the dll to become part of that applications process space ?
My problem is I dont have source code for the target App, so is this going to stop me dead ?

Also, is that problem solved by writing a system hook, or was that how you were recomending to read from the listctrl, once the dll was in the process space ?

cheers !

Author Comment

ID: 1325713
Please see my comments, can you provide some more information ?


Accepted Solution

bitq earned 200 total points
ID: 1325714
I think you may do it this way

First i think that thui was right!
You must write a DLL!
And it's very complex!

1.We gonna get the Handle of the window & the List Box:

you can use FindWindow to find the App's window
the parameters of FindWindow you can get from Spy++
or other tools,get the HWND

if the ListBox in a dialog
that's can get it's ID the only ID
from spy++,then use GetDlgItem() get it.


CWnd *pWnd;

//The windowclass & windowname are const strings
//that you get from spy
CListBox *pListBox;
//THELISTBOX_ID is a const number you get from spy
//So you get the CListBox
//but you CAN'T use GetItemText or others NOW!

2.Write a DLL to broken process wall

If you know little about Hook & dll
i sujest you give up.

you can use a globle GETMESSAGE HOOK
and when you want get some data from ListBox
you can send a USER MESSAGE to the listbox;
you hook func check Handle of HOOK callback func
if same as ListBox you want,call GetItemText

!!AND important!Send a WM_COPYDATA message to your main app
the detail of WM_COPYDATA can got from VC helps.

the code:

in your Dll

#pragma data_seg("mydata",SRW)
BOOL bGetting=FALSE;
HWND hWndToGet;
#pragma data_seg

__declspec(dllexport) void Begin(HWND hWndToWatch)
         hDllMod,//Get at start of dllMain


__declspec(dllexport) void Get(DWORD message)

LRESULT CALLBACK myhookproc(int code,WPARAM wParam,LPARAM lParam)
     MSG *pMsg=(MSG *)lParam;
//         do you work depend on pMsg->message
//you can store the number result such as
//Get GetItemCount in the vars of dll
//but must in share seg
//when you want to send some string or sth
//you must send a WM_COPYDATA message to your
//main app

3.create message maping on WM_COPYDATA
i think it'll work

The code i wrote is simple
I have no much idle
If you don't clear
View MSDN or codeguru etc
And some book's of M$ press

Good Luck!


Author Comment

ID: 1325715
Cheers bitq.

I've not used Hooks before, but have been playing around with a couple of samples from CodeGuru.

I think I'll be able to sort it out from here on in!

thanks again.


Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
cat dog challenge 18 127
move a line in eclipse 3 107
has22 challenge 11 105
either24  challenge 19 101
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

821 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