ToggleProcessProtection Method
Enables or disables termination protection for the application.
function ToggleProcessProtection(Enabled: Boolean): Boolean;
Remarks
This method controls the termination protection mechanism, which applications can enable to prevent their process and threads from being terminated. If successful, this method returns True; otherwise, it returns False.
The Enabled parameter specifies whether termination protection should be enabled (True) or disabled (False); it is disabled by default. If termination protection is enabled, an application must disable it before attempting to exit.
Important: When developing a GUI-based application, please keep in mind that the termination protection mechanism does not intercept window notifications like WM_CLOSE, WM_QUIT, etc.; applications must intercept and handle such messages themselves if they wish to protect their UI. Please refer to Microsoft's Window Notifications articles for more information.