Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Catch file close event

Catch file close event

Scheduled Pinned Locked Moved C / C++ / MFC
csharpcomlinuxtoolsjson
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sudhir Mangla
    wrote on last edited by
    #1

    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)

    G 1 Reply Last reply
    0
    • S Sudhir Mangla

      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)

      G Offline
      G Offline
      Galatei
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups