You can view all files to see if they were locked in Windows.
It is impossible to determine whether a file is opened by the direct user or is simply scanned by another program, for example. search for words.
I suspect that everything you are trying to do is done better or more reliably in a different way.