How to determine what process(es) is(are) locking a file?

This is a discussion on How to determine what process(es) is(are) locking a file? within the Windows Programming forums, part of the Platform Specific Boards category; I have a Java application that uses java.nio.channels.FileLock to obtain a lock on a file. But unfortunately the API does ...

  1. #1
    Registered User
    Join Date
    Dec 2007
    Posts
    3

    How to determine what process(es) is(are) locking a file?

    I have a Java application that uses java.nio.channels.FileLock to obtain a lock on a file. But unfortunately the API does not provide a method to determine when the lock is unsuccessful what process(es) is(are) locking the file. So I am trying to do this using JNI and C, but I have not had any luck finding source code to do this. Does anyone know how to do this? It's only necessary to work with a Windows(XP and up) environment.

  2. #2
    Registered User
    Join Date
    Dec 2007
    Posts
    9
    No real easy way to tell which process has a lock on a file in the API, most of it is undocumented.

    There are tools like Unlocker for one, great app and right click tells you info on it, namley the owning process locking it.

    You can also go into a DOS box and type openfiles for monitoring and control of open files

  3. #3
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  4. #4
    Registered User
    Join Date
    Dec 2007
    Posts
    9
    thank you kindly and I just found out I misspelled my name upon registering. Looks like it's gonna be a long day...

  5. #5
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    1,668
    If you ask an admin (or maybe mod), they should fix the spelling error in your user name.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File transfer- the file sometimes not full transferred
    By shu_fei86 in forum C# Programming
    Replies: 13
    Last Post: 03-13-2009, 12:44 PM
  2. gcc link external library
    By spank in forum C Programming
    Replies: 6
    Last Post: 08-08-2007, 03:44 PM
  3. Batch file programming
    By year2038bug in forum Tech Board
    Replies: 10
    Last Post: 09-05-2005, 03:30 PM
  4. Simple File encryption
    By caroundw5h in forum C Programming
    Replies: 2
    Last Post: 10-13-2004, 10:51 PM
  5. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21