Catch file close event
-
We are creating a Document Management System. In that a user can open the document with associated application. We need to show a lock icon if the file is already open. We open the file in thread using shell execute and then user WaitfForsSingleObject of detect if the file is closed. But if the multiple files are opened (like two files are opened in Acrobat) we are not able to detect if the file is closed. Can some open suggest some API or oter method for detected when the file is closed.
Sudhir Mangla http://Programmerworld.net AND http://DevelopersVoice.com (Free books , articles , Source Code and Programming Tools and Utilities)
-
We are creating a Document Management System. In that a user can open the document with associated application. We need to show a lock icon if the file is already open. We open the file in thread using shell execute and then user WaitfForsSingleObject of detect if the file is closed. But if the multiple files are opened (like two files are opened in Acrobat) we are not able to detect if the file is closed. Can some open suggest some API or oter method for detected when the file is closed.
Sudhir Mangla http://Programmerworld.net AND http://DevelopersVoice.com (Free books , articles , Source Code and Programming Tools and Utilities)
Hi, Some time ago I wrote similiar DMS for some company, but my idea is slightly different than yours. Instead of passing document directly to the application which is associated as default, you could create another file as temporary with additional parameters (temporary, remove on file close, share read/write), copy content of original file to it, open the file with associated app (don't close its handle). Pros: - original file doesn't need to be locked, - you can track changes, - you can let user decide wheter the original file should be updated or not, - you don't have to care about temporary file, unless user closes it, - you can monitor changes made to that file, by using handle to it. Cons: - a bit more code to write, than in simple handle checking :D As for your way, there's a nice tool you can use: Sysinternals - Handle (by dumping its output to your redirected standard output). Regards