Its impossible. You can only post messagees to threads they have a message queue. A process can have many threads - but threads have no names to distinguish them. So far as i know there isnt any function to enumerate all threads of a process - if there is one, to which thread you want to post the message?
Best solution (by my opinion) is to create an invisible dummy window. Then you can broadcast a registered message to communicate with the other process(es).
Regards.
[Edit]
apllication 1
void main()
{
int mterm = RegisterWindowMessage("MyTermMessage");
HWND hwnd = CreateWindowEx(0,__T("STATIC"),__T(""),0,0,0,0,0,0,0,0,0);
for(MSG m;GetMessage(&m,0,0,0);DispatchMessage(&m))
{
if(mterm==m.message)
PostQuitMessage(0);
}
DestroyWindow(hwnd);
}
application 2
void main()
{
int mterm = RegisterWindowMessage("MyTermMessage");
unsigned long to = BSM_APPLICATIONS;
BroadcastSystemMessage(BSF_IGNORECURRENTTASK|BSF_POSTMESSAGE,&to,mterm,0,0);
}
You need a dummy window to receive the broadcasted message(s) - thats because you cannot post messages to unknown threads. As i explained - there is no function to get a thread id from another process.
Regards.