Created
July 21, 2022 17:35
-
-
Save JTheiller/71817fa04d3f7c75e5baf6aeeec47073 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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