Re: Strange problem with "On-Screen Keyboard" and CreateProcess
"Tom Becker" <Tom_dot_Becker_at_Ziemann_minus_Urban_dot_de> wrote in message
In my application (MFC MDI) I want to display an "On-Screen Keyboard".
As WinXP has one on board (osk.exe), I've decided to use this one.
This is the way I do it:
memset(&sI, 0, sizeof(sI));
sI.cb = sizeof STARTUPINFO;
if(!CreateProcess(NULL, m_oskPath, NULL, NULL, FALSE, 0, NULL, NULL, &sI,
//Do something with the keyboard
//Either use the hard way
//OR maybe a better solution
//BTW. WM_CLOSE does not work. osk.exe remains active
::PostThreadMessage(pI.dwThreadId, WM_QUIT, 0, 0);
DWORD exitCode = STILL_ACTIVE;
while(exitCode == STILL_ACTIVE);
This works nearly perfect.
My problem is another process created by osk.exe. The name is
This process remains active after closing osk.exe with one of the two
described solutions. It does not matter which of the solutions I take.
Even worse, everytime I start a new instance of osk, a new instance of
is created and remains in memory.
Can anyone tell me how to solve this?
When I close osk.exe manually by pressing the Close-Button both processes
Tom, try posting WM_SYSCOMMAND with SC_CLOSE to simulate clicking the 'X' in
the osk caption. But don't do a PostThreadMessage(), which can fail if the
thread has created windows. Instead, iterate the top level windows of the
osk.exe process using EnumThreadWindows (the thread you want is
pi.dwThreadId) and post this to each of them.
Another thing: when waiting for the osk.exe process to terminate, do a
WaitForSingleObject(pi.hProcess) instead of polling the exit code. Far
better. And don't forget to CloseHandle() the handles in pi (pi.hProcess