Hi everybody,
For a kiosk application, I'm trying to start an application through code,
and later on kill the same application. With a standard application, it
works like a charm.
But when I try to do the same with explorer.exe, I can't kill the
process. The reason is most likely the fact that there is always only one
explorer.exe process, albeit with multiple windows.
Here is my code:
// create the process
procedure TForm1.CreateClick(Sender: TObject);
var
sProgram: String;
zCommand: array[0..512] of char;
si: TStartupInfo;
dwError: DWORD;
begin
sProgram := 'c:\winnt\notepad.exe';
if (Pos(' ', sProgram) > 0) and (sProgram[1] <> '"') then
sProgram := AnsiQuotedStr(sProgram, '"');
StrPCopy(zCommand, sProgram);
FillChar(si, SizeOf(si), #0);
si.cb := SizeOf(si);
si.dwFlags := STARTF_USESHOWWINDOW;
si.wShowWindow := SW_SHOWNORMAL;
if CreateProcess(nil, zCommand, nil, nil, False,
CREATE_NEW_CONSOLE or NORMAL_PRIORITY_CLASS,
nil, nil, si, FProcessInfo) then
begin
end
else
begin
ShowMessage('Createprocess failed!');
end;
end;
// kill process
procedure TForm1.KillClick(Sender: TObject);
var
uExitCode: Cardinal;
sAuto: String;
begin
uExitCode := 0;
if TerminateProcess(FProcessInfo.hProcess, uExitCode) then
begin
ShowMessage('Terminated');
end
else
begin
ShowMessage('Termination failed!');
ShowMessage('Exit code: ' + IntToStr(uExitCode));
end;
end;
// end code snippet
Does anybody know a way to kill one particular explorer.exe window?
Thanks in advance!
Ikke


|