Posted on 2017-10-01
My Application uses FdMemTable and load a file called users.xml. every thing is nice until I the application is used by local network.
Several users try to open the same file at the same time! An exception rises!
I found a function that might help me but "createFile" is not recognized also GENERIC_READ or GENERIC_WRITE by the compiler. Please Help!
function TDataContainer.IsFileInUse(fName : string) : boolean;
var //fNAME is the adress of the file to check if is in use
HFileRes : Thandle;
Result := false;
if not FileExists(fName) then exit;
HFileRes :=createfile(pchar(fName),GENERIC_READ or GENERIC_WRITE,0, nil, OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0);
Result := (HFileRes = INVALID_HANDLE_VALUE) ;