Access denied with GetWindowLong(Hwnd,GWL_WNDPROC)???

Cina
Cina used Ask the Experts™
on
I tried to catch messages from a window that I can correctly find with EnumWindows/EnumChildWindows, and has the correct handle for it (I checked with WinSight32).
When I tried to get the WinProc of that window (it's classname is 'SysTreeView32') with GetWindowLong I get an error message of 'Access denied' - GetLastError gives back 5.
I can get the ClassWndProc without any error.
WinSight32 and Spy++ correctly gets the messages. I use WinXP professional as an OS and I logged in with an admin user. Where is the problem?
Thanx for the answers...
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Hello Cina, you can NOT use a memory address of another Process, the access violate, is because the memory is in another process, The API help says

Calling SetWindowLong with the GWL_WNDPROC index creates a subclass of the window class used to create the window. An application should not subclass a window created by another process. .

Author

Commented:
I'm not quite sure. WinSight/Spy++ can see these messages even they get the address of the WndProc for each window/childwindow (probably with GetWindowLong). I don't know how they do it. Any idea?
I can only guess, , probally with a Hook, or several hooks, what messages are you wanting to get?
Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

Author

Commented:
Especially I want to track down some information of a SysTreeView32 component. (Kazaa download and upload windows) I want to read out the info displayed inside the window. TVM_GETITEM / TVM_SETITEM.
I managed to send message to the control (TVM_GETNEXTVISIBLE/TVM_GETNEXTSIBLING/TVM_SELECTITEM, etc.) and list out the HTREEVIEW pointers correctly, but I couldn't manage to get the program accept any TVM_GETITEM message from me. I traced with Spy++ the messages which gives back TVITEMs correctly. Probably the data I search is inside one of the TVITEM items, but the SendMessage always returns 0 (instead of 1) which is also can be seen inside Spy++.
If you could send me a reference to any Hook like example that would help me a lot. Thanx.
I might could fimd some code to hook another program and subclass a TreeView control, but doing that and then getting and using it's data may not be real simple, I'll look
as Slick812 said, you cannot access another process' memory address... however you can 'abuse' SetWindowHook by injecting your message proc into the process

here's one example on how to inject into the process.
http://www.experts-exchange.com/Programming/Programming_Platforms/Win_Prog/Q_20274015.html

Author

Commented:
Ok I'm trying out madshi's inject DLL and HookCode routines. I hope I'll get it work. Thanx anyway. 've got a lot to learn.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial