Thanks for your answers, Jochen and Garth.
The program that I need to control is not my application, it's a comercial program. I yet found the GetProcessTimes, but this function does not return the time that I need.
Neither found the solution with the Process Class.
The solution can be to use one of these programs:
Idle Software Closer - Automatically Close Programs Concurrent License[
^]
Auto Close Idle Programs, Accounting, Financial, and Database applications[
^]
One solution to try to do it myself can be to check continuously if the program is idle or not, and control with a timer when I detect that it is idle. But, as far as I checked, none of both solutions returns if the Windows program is idle or not.