Reputation: 927
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.
Upvotes: 0
Views: 205
Reputation: 10862
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
Upvotes: 0