Click here to Skip to main content
15,888,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear all,

When we open the specific device port using CreateFile, it may fail by the error ERROR_SHARING_VIOLATION.
This means 'The process cannot access the file because it is being used by another process.';

I would like to kill that process which preacquired the device manually.
Could you give any ideas to get the process ID or handle to trigger the kill command?

Thanks in advance,
Jay
Posted

1 solution

It's a nice idea on paper, but all you end up doing is corrupting the data in the file your trying to read.

Killing another process is not a safe way to go about getting your hands on the contents of a file.

Also, in order to kill a process running as another user, your code has to be running as an admin. Just to enumerate all the handles, you have to be an admin.

What are you ultimately trying to do with this that makes you think you need to do something so drastic??
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900