How do i detect that a file is been used by another program?

Much Appreciated!