Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

locked file

Posted on 2008-10-15
5
Medium Priority
?
330 Views
Last Modified: 2013-12-04
Hi,

Is there a way to detect a locked file without trying open that file first?
Thanks,
0
Comment
Question by:mycuti08
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 2

Expert Comment

by:mannujam
ID: 22730203
Se if this article can help you. You can have a log if it is locked
http://windowsxp.mvps.org/processlock.htm
0
 

Author Comment

by:mycuti08
ID: 22730314
Thanks for the answer, but I'm looking for a programmatical solution.
0
 
LVL 2

Accepted Solution

by:
mannujam earned 1500 total points
ID: 22730661
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
 

Author Comment

by:mycuti08
ID: 22730719
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
 
LVL 49

Expert Comment

by:DanRollins
ID: 22736552
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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Compliance and data security require steps be taken to prevent unauthorized users from copying data.  Here's one method to prevent data theft via USB drives (and writable optical media).
Know the reasons and solutions to move/import EDB to New Exchange Server. Also, find out how to recover an Exchange .edb file and to restore the file back.
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question