Strange problem with "On-Screen Keyboard" and CreateProcess
Hallo
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:
PROCESS_INFORMATION pI;
STARTUPINFO sI;
memset(&sI, 0, sizeof(sI));
sI.cb = sizeof STARTUPINFO;
if(!CreateProcess(NULL, m_oskPath, NULL, NULL, FALSE, 0, NULL, NULL, &sI, &pI))
{
//Display Error
SysErrMsgBox(GetLastError());
}
else
{
//Do something with the keyboard
...
//Either use the hard way
//::TerminateProcess(pI.hProcess, 0);
//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;
do
{
Sleep(0);
if(!GetExitCodeProcess(pI.hProcess, &exitCode))
{
//Display error
SysErrMsgBox(GetLastError());
break;
}
}
while(exitCode == STILL_ACTIVE);
}
This works nearly perfect.
My problem is another process created by osk.exe. The name is "msswchx.exe"
This process remains active after closing osk.exe with one of the two above
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 "msswchx.exe"
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 are terminated.
thx
Tom Becker