Your method is basically correct and should work, but it is destructive, you may want to use read instead or check stream size. The problem is that the file could be opened for non-exclusive access, which is not very typical but your method of detection won't detect it.
You can try this:
http://read.pudn.com/downloads36/sourcecode/windows/111597/NtSystemInfo/NtSystemInfoTest/NtSystemInfoTest.cpp__.htm[
^].
Also, it may happen that you think the file is opened but actually it is not. Please check it up. For example, many text editor do not keep a file handle open. They open a file, read it all into the application's memory and close immediately. File is read and not opened. You can check up what really happens using Sysinternals Process Explorer: see Sysinternals Suite:
http://technet.microsoft.com/en-us/sysinternals/bb842062[
^].
—SA