>Take a look in Sergey's answer but keep in mind that if You (someone) open the file with Notepad FOPEN() returns a valid file handler.
In such case the file isn't technicaly open because Notepad and some other editors work with the copy of the file in the memory.
--sb--