Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 332
  • 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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