Skip to content

Latest commit

 

History

History
20 lines (16 loc) · 481 Bytes

README.md

File metadata and controls

20 lines (16 loc) · 481 Bytes

Delphi.GetProcessReservingFile

Method to get process that has file opened, if any.

Heavily influenced by: https://devblogs.microsoft.com/oldnewthing/20120217-00/?p=8283

Usage

try
  OpenAndProcessFile(LFileName);
excpet
  on E: Exception do
  begin
    ...
    if GetProcessReservingFile(LFileName, LProcessFileName) then
      LErrorMEssage := LErrorMEssage + ' The process that is holding your file as a hostage is: "' + LProcessFileName + '"';
  end;
end;