Solved

locked file

Posted on 2008-10-15
5
321 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Recently Microsoft released a brand new function called CONCAT. It's supposed to replace its predecessor CONCATENATE. But how does it work? And what's new? In this article, we take a closer look at all of this - we even included an exercise file for…
If you get continual lockouts after changing your Active Directory password, there are several possible reasons.  Two of the most common are using other devices to access your email and stored passwords in the credential manager of windows.
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

706 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now