but my problem is an other. i dont want to know whether the file is lockt, i want to know whether the file is opened. i copy a "BLOB" from an database to the local hdd, progress have to know whether the file is opened on local pc, when it is not opened, progress can copy it back to database and can delete the local file.
Well there are a couple of WinApi Open / Lock methods that you can call passing a 'Share Exclusive' parameter, which will deny access to other processes.
If the file is already open, the call fails - which gives you your IsFileOpen test.
You may also be able to do this with the CreateFile call in the David Rozen link I posted, but I don't think the parameter applies in that case.
Apparently, setting dwshare mode to 0 with CreateFile means it can't be shared - which may do what you want - and you already have code to experiment with.
Here's a Knowledge base entry with a stupid title that has an example, although you may need to experiment with the READ/WRITE parameter.
P26125
Title: "How to check if a file is busy using 4GL?"
i don't think you can tell whether a file is still open in some app. worst case, an app can just read the file into memory and be done with it.
but most modern app lock files while editing e.g. excel, word etc.
another thing you can do is use shellexec to launch the app and open/edit document and write a process (you could use pstimer) that checks whether the app process has been closed.
but even that won't work all the time. some apps use mdi in which case you'll get multiple windows/files for a single process (or something like that ?).
maybe a cross between them will cover most cases ?
you could issue a notice in cases that don't, telling the user the file would have to be loaded manually.
personally, i wouldn't do neither of them.
start by letting the users save the file to disk and load them back after they've finished making changes.
later on when you've got everything together or a better idea you can gradually improve on it. hth
If you don't get anywhere with the previous suggestions, try querying the output from this cool little util (can be run from the command line, so you should be able to call it from 4GL).
It's extremely fast, and reports all opened files to a format you choose (XML/Text/etc.).
thanks for all your suggestions, im really responsive about the helpfulness in this forum.
Regrettably, im unable to engage with it, im trainee as IT specialist and my project (document-storage in an production planning and control system) must be complete in 2 weeks. I wont make a lock on the database when a file is in use, everybody can open and save every document at every time, changed documents will save in a new version of it. i think that is the easiest way.
thanks again, i will visit the forum from time to time.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.