I'm trying to make a program that calculates how long one particular text file is being kept open by any other process (text editor). So, does anyone know how to detect that file is opened by another process and then detect if it's closed (even if nothing was changed).


Thanks for quick reply, but I used completely wrong word. I need to spy on other APPLICATION, not process, and so I don't have the File handle. I hope there is a flag, which is set when File is in use. Then I could record the time when file went into use and afterwards record the time when other application has closed the file handle.

Posted on 2002-11-23 14:24:49 by prints
Just time how long the process exists. Use CreateProcess to start it, save current time, then WaitForSingleObject(hProcess, INFINITE), and subtract saved time from current time.
Posted on 2002-11-23 14:36:07 by comrade