You could also use the command-line tool lsof to list open files. Pipe the results into grep with the file path you want to check, like so:
lsof | grep "/path/to/file"
You can also call external commands from C. I forget the exact function call to do it in "raw" C (been using Python and Cocoa for so long...).
Note that you might want to do "sudo lsof" instead, since lsof run as an ordinary user will only return files open by that user, not system processes.
I use this technique in Terminal quite often when disks fail to eject because "a file is in use". "sudo lsof | grep /Volumes/Drive_Name" usually tells me what program I need to quit.