Solved

locked file

Posted on 2008-10-15
5
323 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
  • 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 500 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
When you try to extract and to view the contents of a Microsoft Update Standalone Package (MSU) for Windows Vista, you cannot extract the files from the MSU. Here we are going to explain how to extract those hotfix details without using any third pa…
This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

777 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