SendMessage does not pass your string to Notepad.
A really minimalistic overview: all the windows architecture is based on messages. If you move your mouse it generates a message, if you press a key, it generates a message... and so on. There are
plenty of message[
^] types. The messages are passed from top to bottom and can be handled by the applications. Just do a quick tour with
ManagedSpy[
^], or other tools to see the messages and the queues. Even if your API is mostly hiding this from you, your application has a message queue a dispatcher and some handlers. See following brief overview:
http://www.tenouk.com/visualcplusmfc/visualcplusmfc2.html[
^]
Now in your case notepad simply receives a text input message from the system - not from your code, you just post the message in the system queue addressed to that window. Please note, that the message target is the window, not the application.
Even if you have a user defined message type, it is quite uncommon to use it as IPC. It is reliable on it's own, but not developer friendly and has several limitations. But see following sample of how to do it, if you really want:
http://code.msdn.microsoft.com/windowsdesktop/CppSendWMCOPYDATA-f75bc681[
^]
For more common IPC possibilities I suggest you start here:
Windows IPC[
^].
http://code.msdn.microsoft.com/windowsdesktop/CppNamedPipeServer-d1778534[
^]
http://www.codeguru.com/cpp/w-p/system/sharedmemory/article.php/c2879/Shared-Memory-Inter-Process-Communication-IPC.htm[
^]