2

Is it possible to pass char* between 2 applications using a custom message in SendMessage? I know it is possible using WM_COPYDATA, but I want to know if I can send this using custom message(WM_USER + ..)

Thank you!

3 Answers 3

7

WM_COPYDATA has been specifically invented because what you ask is not feasible directly. This because different applications live in different address spaces, so a pointer passed from an application has no meaning in another one.

WM_COPYDATA deals with the problem by using some IPC mechanism under the hood, which is what you usually do when you want to share data with another application; viable options are the usual ones: pipes, shared memory & co, have a look here to see what Windows provides.

Sign up to request clarification or add additional context in comments.

2 Comments

@David: no problem, I'll remove mine. :) By the way, you may be interested to have a look at the series about GlobalAlloc on Raymond Chen's blog, it describes in detail all the transitions it traveled through before becoming just a wrapper for LocalAlloc; quite an interesting read if you like an historical approach to Win32. :)
I'm sure I have read it once upon a time, and it seems I need to revise my knowledge!!
2

I'm nearly certain that's not possible. The other app won't be able to read directly from a pointer to the first app's heap/stack.

Comments

1

Here is good article which will help you in interprocess communication. It was helpful for me in sending string between two application.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.