[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 336
  • Last Modified:

locked file

Hi,

Is there a way to detect a locked file without trying open that file first?
Thanks,
0
mycuti08
Asked:
mycuti08
  • 2
  • 2
1 Solution
 
mannujamCommented:
Se if this article can help you. You can have a log if it is locked
http://windowsxp.mvps.org/processlock.htm
0
 
mycuti08Author Commented:
Thanks for the answer, but I'm looking for a programmatical solution.
0
 
mannujamCommented:
Yah if executable is free you can use it programatically in your code .
One other way is to get into all executables  memory and
determine how many handles a process has open, but you have to go down to kernel level to map the handles to processes. This way you can do it easily.
0
 
mycuti08Author Commented:
I prefer the latter. Once you get to the handles that a process opened, can you tell if there is flag or something like that associated with a handle to indicate the file is locked or not?
0
 
DanRollinsCommented:
The source code provided in this article:

   Examine Information on Windows NT System Level Primitives
   http://www.codeguru.com/Cpp/W-P/system/processesmodules/article.php/c2827
should get you started.
The normal way to test is a file is locked is to simply try to open it for write access and the note if thatopen fails.  I know that you want to find an alternate methid but that is fastest and easiest.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now