Go Premium for a chance to win a PS4. Enter to Win


CListCtrl->GetItem() across processes

Posted on 1998-12-03
Medium Priority
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 800 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 fine.you 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

916 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