What Win32 API can be used to find the process that has a given file open?

后端 未结 2 989
臣服心动
臣服心动 2020-12-16 00:45

If I read or write to a file and receive a 33 or 32 error, I would like to log a message containing the name of the other process(es) that have the file opened. There must b

相关标签:
2条回答
  • 2020-12-16 01:34

    The Handle program from SysInternals does this as well, but I'm not sure how. I don't think there is a single documented API to do this. I think you have to iterate over the processes, enumerate each of the handles in the process, and then determine the filename associated with that handle.

    0 讨论(0)
  • 2020-12-16 01:36

    This seems to do what you want.

    obviously it uses some hidden API such as NtQueryInformationProcess.

    0 讨论(0)
提交回复
热议问题