Well in order to use custom messages, they need to be defined as a value greater than WM_USER. So, if I wanted a message like WM_MYMESSAGE:-
The only problem is: what's stopping another program from doing the same thing for its own messages?
#define WM_MYMESSAGE (WM_USER + 1)
The answer: RegisterWindowMessage.
The return value of RegisterWindowMessage is guaranteed to be unique across the entire system and within the range WM_USER to 0x7FFF. As many applications that use the message may call RegisterWindowMessage, they will all get the same value to use.
unsigned int uiMessage;
uiMessage = RegisterWindowMessage("WM_MYMESSAGE");
So, you've done all that, now what about passing stuff? Passing an integer here and there is easily done, wParam and lParam are at your disposal...
BUT... what if you want to pass a string, or a pointer to a structure? Then things get tougher. The thing is, each process's memory is protected from other processes. They can't just pop inside each other's address space and compare notes. What you need is, specifically for messaging, some shared memory. This is known as custom marshalling.
LRESULT WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
if (wParam == 1)
MessageBox(hwnd, "Woot!", "Hello!", MB_ICONEXCLAMATION);
And it's not something I know how to do.