Skip to content

Instantly share code, notes, and snippets.

@JTheiller
Created July 21, 2022 17:35
Show Gist options
  • Save JTheiller/71817fa04d3f7c75e5baf6aeeec47073 to your computer and use it in GitHub Desktop.
Save JTheiller/71817fa04d3f7c75e5baf6aeeec47073 to your computer and use it in GitHub Desktop.
function FileInUse(AFileName: String): Boolean;
var
HFileRes : HFILE;
begin
Result := false;
if not FileExists(fName) then
Exit;
HFileRes := CreateFile(PChar(AFileName), GENERIC_READ or GENERIC_WRITE,0, nil, OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL, 0);
Result := (HFileRes = INVALID_HANDLE_VALUE);
if not Result then
CloseHandle(HFileRes);
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment