Results 1 to 2 of 2

Thread: Unlocking a file (Check for attached dll)

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2010
    Posts
    82

    Unlocking a file (Check for attached dll)

    I know how to display attached modules but how do i check if a file is locked by a dll.

    thanks

  2. #2
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: Unlocking a file (Check for attached dll)

    A DLL cant lock a file on its own - a process calling functions from a DLL could lock a file, but you cant just say a DLL has locked a file because one process could be using that DLL and locking a file but another process could be using that DLL and not locking any files. I'm guessing the only reason you would want to know what is locking a file is so that you can do something about it... and you cant do anything about it just by knowing which DLL holds the function that is locking the file - you need to know which process it is that is locking the file.
    So personally I would have thought the only way you could find out which process is locking a file is to loop through all active processes and enumerate the handles that each process has. I dont think there is any way in .NET to get a list of the open handles that a process has though so you would probably have to look at some Windows APIs and even then I'm guessing it will not be a trivial task to actually find out which handles relate to which object (I say object because a process can have handles to more than just files, it can be registry keys, kernel objects etc). I might be wrong, there might be an easy (ish) way to do it but I think this might require quite a lot of work. Its definitely possible as programs like Process Monitor can list all open handles for each process, but then they are written in C++...
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width