Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

SetWindowLong to other process under Windows95/98

64 views
Skip to first unread message

Eli Golovinsky

unread,
Jan 27, 2001, 2:04:55 PM1/27/01
to
MSDN points out about the SetWindowLong funciton that:
"Windows 95/98: The SetWindowLong function may fail if the window specified
by the hWnd parameter does not belong to the same process as the calling
thread. "

Does anybody know how can this be resolved, preferably without attaching the
window to my process?

David Lowndes

unread,
Jan 28, 2001, 1:05:50 PM1/28/01
to

Eli,

What are you trying to do that requires you to do this (perhaps
there's an alternative)?

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq
My address is altered to discourage junk mail.
Please post responses to the newsgroup thread,
there's no need for follow-up email copies.

Jussi Jumppanen

unread,
Jan 28, 2001, 4:17:36 PM1/28/01
to

I would be very suprised if Microsft allowed you do this. Any program
that uses the SetWindowLong usually stores a pointer in the GWL_USERDATA
and if Microsoft allowed this sort of cross application call it would
be so easy to crash any program that used user data.

Jussi Jumppanen
Author of: Zeus for Windows, Win32 (Brief, WordStar, Emacs) Text Editor
"The C/C++, Java, HTML, Pascal, Cobol, Fortran programmer's text editor"
http://www.zeusedit.com

James Brown

unread,
Jan 28, 2001, 6:18:52 PM1/28/01
to
You can't do it unless you "attach" youself to the remote process,
as you put it. It's pretty straight-forward - get the Advanced Windows
book by Jeffrey Richter - he demonstrates how to do this.

Basically, you need to write a dll which you inject into the foreign
process using a message hook on that application.

By the way, SetWindowLong wont always fail - you can probably
set the GWL_USERDATA and GWL_ID fields OK, but the call
definitely will fail if you try to modify the GWL_WNDPROC to subclass
the window. You need the DLL injection method in this case.

'Ain't no other way, sorry...
James

"Eli Golovinsky" <gtr...@mailandnews.com> wrote in message
news:94v6ei$ipa$1...@news.netvision.net.il...

Sébastien COTON

unread,
Jan 29, 2001, 11:20:39 AM1/29/01
to
I suggested you to try the SetWindowProp and GetWindowProp function in order
to bind value to a window.

Sébastien COTON


0 new messages