function IsFileInUse(fName: string): boolean;<br>var<br> HFileRes : HFILE;<br>begin<br> Result := false;<br> if not FileExists(fName) then exit;<br><br> HFileRes := CreateFile(pchar(fName), GENERIC_READ or GENERIC_WRITE,<br> 0, nil, OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL, 0);<br> Result := (HFileRes = INVALID_HANDLE_VALUE);<br> CloseHandle(HFileRes);<br>end;