|
-
September 22nd, 2009, 04:57 AM
#1
File In Use
Hello.
The Problem:
I want to determine if a file is opened/ in use by another program.
What I'm up to:
I've learned that if I use
CreateFile(szFile, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)
and if some program, let's call it APP_1, opened szFile in exclusive mode before, CreateFile returns an ERROR_SHARING_VIOLATION error. Ok so far. But I can't find a way to know if APP_1 opened the file just to read because CreateFile opens the file and does not say what I want.
I had an ideia that if I used MoveFile, if the file was opened by someone, MoveFile would return an ERROR_SHARING_VIOLATION. But, this solution is poor because MoveFile will return ERROR_ACCESS_DENIED if I do not have permission to write there....
What I would Like to know:
Is there a way (I know there is!!!) to know in my system or in LAN if a resource/file is being used by another program?
Thanks in advance
Can't get me out of the race, babylon see me face
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|