Jump to content
Sign in to follow this  
Tommi Prami

Lib for Getting process name that has the file open

Recommended Posts

Really interesting, knowing if a file is already in use by another application via an api instead of trying to open it and manage the error (without knowing "who" is blocking it anyway) is very useful in some scenarios.

 

Bye

 

Share this post


Link to post
16 hours ago, DelphiUdIT said:

Really interesting, knowing if a file is already in use by another application via an api instead of trying to open it and manage the error (without knowing "who" is blocking it anyway) is very useful in some scenarios.

 

Bye

 

This might be slow and resource intensive, depending on situation. 

My idea of pseudocode pattern would be something like.
 

try
  FileOperations(LFileName);
except
  on E: Exception do
  begin
     ...
     if GetProcessReservingFile(LFileName, LProcessFileName) then 
       LErrorMessage := LErrorMessage + ' File is being used by ' + LProcessFileName;
     ...
  end;
end;

 

But everything depends on the situation.  Anyhow, user most likely would like  to know what app has the file is opened. 

 

-Tee-

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×