Hello
for example i have a buffer that contain a text string,i want to send it to another program that i know it's window handle:

Can i send a message to it whit wparam that contain address of buffer?:(
but i think each program has a rang of memory that just it cat address it.

Thanks
Hamed
Posted on 2002-04-03 06:53:24 by hamed_hhz
SendMessage + WM_SETTEXT should work well...
Posted on 2002-04-03 07:40:55 by JCP
WM_COPYDATA should also do the work well.
SendMessage(
(HWND) hWnd, // handle to destination window
WM_COPYDATA, // message to send
(WPARAM) wParam, // handle to window (HWND)
(LPARAM) lParam // data (PCOPYDATASTRUCT)

typedef struct tagCOPYDATASTRUCT {
ULONG_PTR dwData;
DWORD cbData;
PVOID lpData;
} COPYDATASTRUCT, *PCOPYDATASTRUCT;

Members:
dwData
Specifies data to be passed to the receiving application.
cbData
Specifies the size, in bytes, of the data pointed to by the lpData member.
lpData
Pointer to data to be passed to the receiving application. This member can be NULL.
Posted on 2002-04-03 12:00:53 by LuHa
what you want is called IPC (inter-process-communication)
these are the ways I know of so far...

wm_copydata, file mapping, pipes, sockets, clipboard,
mutexes, events, hooks
Posted on 2002-04-04 02:38:10 by mob
I am wondering wtch one you can use that will not be globle or easily seen through other running process's when your program is in the process of doing this.

My guest would be Pipes or mutexes. Pipes sound like nothing else should ever have a chance to intrude just like a water pipe. But it might not mean that in Windows. I really don't know.

And suppose it is one of your OWN sepreate program that you want to do this with.

"wm_copydata, file mapping, pipes, sockets, clipboard,
mutexes, events, hooks"
Posted on 2002-04-04 03:13:32 by cmax
mh i think you can use all of them... all the other programs
just do their thing and normaly do not respond to ipc... but
i wouldn't use ipc for security-related things... i think allmost
every technique to do ipc could be hooked... but for normal
progs it doesn't matter i think...


And suppose it is one of your OWN sepreate program that you want to do this with.


it HAS to be one of your own progs... sure, you can flood other
progs easily with wm_copydata but those apps can't handle
it...

oh, and in my opinion WM_SETTEXT changes only the caption-
title of a window...
Posted on 2002-04-04 04:42:41 by mob
This is Great to know. And that is a shock to me about WM_SETTEXT. I think it does more than just that. I got to look into it. Come to think of it you use WM_SETTEXT for just about anything. How about when you set text in a edit box. I think that one slip pass you. I could be wrong.

Thanks mob
Posted on 2002-04-04 04:52:04 by cmax
oh, and in my opinion WM_SETTEXT changes only the caption-
title of a window...


The original question is not clear enough... if you have a handle to a window and want to transfer a string pointer, there is some probability that is to change the caption of a window...
Posted on 2002-04-04 05:00:15 by JCP
A while ago I did some work on memory mapped files and between them and direct messaging, you can write applications that communicate in very efficient ways with both data and actions through messages.

Regards,

hutch@movsd.com
Posted on 2002-04-04 06:40:36 by hutch--

Come to think of it you use WM_SETTEXT for just about anything. How about when you set text in a edit box. I think that one slip pass you. I could be wrong.


no, you aren't... mh maybe my words wasn't clear enough...
i know you can change the text in edit-windows or in window
caption with WM_SETTEXT but you can't or shouldn't use it
for ipc :)

hutch, i used mem-mapped files for ipc too and i think it's
a good way to do it but it was very complicated because
of syncronisation problems... can you release your results?
Posted on 2002-04-04 08:54:46 by mob
Mob,

This is the demo I posted a while ago. The synchronisation problems depend on how you write the communication betwen the 2 or more files that use the MMF. My own view is that you arbitrarily set aside some of the memory address space and fill it with things like handles and even flags so that each app know what is happening.

Regards,

hutch@movsd.com
Posted on 2002-04-04 18:06:49 by hutch--