Closing a process child window (e.g. a Word window) accessing a specific file
Scenario (for force deleting a file, can't go for delete on restart):
Given the above scenario, I have done the following:
Found the process (instance of Process class) accessing my target file using the code here
Found a list of handles held by that process (using NtQuerySystemInformation() method).
How do I find that particular window handle that is related to the file handle I found in step 3 above? My plan is to use SendMessage() method with WM_CLOSE message to that particular window so it would be closed and my file would be released.
One way is to check the file name string in that child window's title and then close that window. But the issue is, a file with the same name could have been opened from some different location.
I found this very detail post about the subject, maybe it can help you
http://forum.sysinternals.com/howto-enumerate-handles_topic18892.html
That post hase some disucussions and related questions here
http://forum.sysinternals.com/topic19403.html
链接地址: http://www.djcxy.com/p/40550.html上一篇: 如何以编程方式删除文件?