So I have 2 programs, let's call em main and alt for now.
Ok, so I've tried looking into this and if I understand it correctly I need to call
poke = RegisterWindowMessage(L"Monocle_poke");
in both programs. I load the second program using:
bool open, DWORD idthread and uint poke are all globals in main.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
DWORD WINAPI ThreadProc( LPVOID lpParameter)
{
if(!open){
open = true;
STARTUPINFO si = { sizeof(si) };
PROCESS_INFORMATION pi;
char * cstr, *p;
wstring str = (L"alt.exe");
if(CreateProcess(0, &str[0], 0, 0, FALSE, 0, 0, 0, &si, &pi))
{
// optionally wait for process to finish
WaitForSingleObject(pi.hProcess, INFINITE);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
open = false;
}
}
return 0;
}
| |
which is called from another function that has
1 2 3 4 5 6 7 8 9
|
if(open){
PostThreadMessage(
idthread,
poke,
wp,
lp
);
} else
CreateThread(0, 0, ThreadProc, 0, 0, &idthread);
| |
in my message handler in alt, I check if the message == poke, and that is never the case.
I also tried to send WM_CLOSE but that doesn't work either.
What am I doing wrong? and if I'm doing something entirely too complicated for my own good, can I send one of the standard messages (like WM_LBUTTON_UP, which does almost exactly what I want poke to do) instead? and how?