How to kill inactive session from Forms

Technology: Oracle Forms 6i, Oracle Database 9i or greater

One of my friend asked how we can kill an inactive session of forms. In an Application server environment this can be attained by modifying none of the application. But as the version is not of our discussion it will not be discussed here.

Here is how we have attained such a result:

We have to use the D2KWUTIL.PLL. In the WHEN-NEW-FORM-INSTANCE trigger provide the following code:
declare
lwindow PLS_INTEGER;
ltimer TIMER;
begin
lwindow := get_window_property(FORMS_MDI_WINDOW,WINDOW_HANDLE);
Win_API_Session.Timeout_Start_Timer(lwindow);
ltimer := Create_Timer('TIMER1',1000,repeat);
end;

In WHEN-TIMER-EXPIRED trigger provide the following code:
begin
if upper(get_application_property(TIMER_NAME)) = 'TIMER1' then
:control.inactive_time := Win_api_session.Timeout_Get_Inactive_Time;
if : control.inactive_time > 120 then
Win_API_Session.timeout_delete_timer;
exit_form (NO_VALIDATE);
end if;
end if;
end;

Control is a block and inactive_timer is a text item. It need not be displayed in any canvas.