Hello.

My process termination code can't terminate calculator. But it can terminate notepad, why?

Also, When I tell it to terminate notepad, it asks me if I want to save the file, meaning, it does not forcefully terminate notepad.

I want it to terminate it immediately without any dialog boxes or anything.

Could someone please help me with the two problems above?

The code:

procedure TERMI_PROC(pWindowHandle: HWND);
var pProcessID: Integer;
var ProcessHandle: THandle;
var dwResult: DWORD;
begin
SendMessageTimeOut(pWindowHandle, WM_CLOSE, 0, 0, SMTO_ABORTIFHUNG OR SMTO_NORMAL, 5000, dwResult);
if isWindow(pWindowHandle) then
begin
GetWindowThreadProcessID(pWindowHandle, @pProcessID);
if pProcessID <> 0 then
begin
ProcessHandle := OpenProcess(PROCESS_TERMINATE OR PROCESS_QUERY_INFORMATION, False, pProcessID);
if ProcessHandle <> 0 then
begin
TerminateProcess(pWindowHandle, 0);
CloseHandle(pWindowHandle);
end;
end;
end;
end;

Thank you.