• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 138
  • Last Modified:

Open Document Hook

I are writing a document management system and need to find a way to be notified when a document is about to be opened in a particular directory.  The document could be opened via an Olelink, hyperlink or just double clicking.  It needs to work for any document type (word, excel, txt, etc..)

I've been looking at namespaces, shell extensions, FindFirstChangeNotification and urlmon but haven't found anything yet.  I really don't want to have to write a Vxd to do this.  There has to be another way

Any suggestions you can give would be greatly appreciated.
0
therichardsons
Asked:
therichardsons
  • 2
1 Solution
 
mikeblasCommented:
Why does there "have" to be another way?  There really isn't.

Simply put, there's no mechanism in Windows to notify other applications of an application's particular decision to perform some arbitrary action. Just think of it: the performance and security implications are enormous.

You can get close to what you want with specific applications that have automation interfaces which might let you query the state of the application.

You won't get what you want with a VXD. The VXD can tell you that a particuar file has been opened by a particular process (see http://www.sysinternals.com/ for samples of such code), but you have no idea _why_ the code opened the file. Maybe it's a backup program doing a backup; maybe it's a user opening the document. Further, you don't know what a file is _for_; it could be code, it could be temporary file, it could be a document.  There's no way to tell with 100% certainty.

You _might_ be able to get someplace with the OLE running object table. If you poll the ROT, you might see that applications you recognize are now running.  Once they're running, you can poll them to see if they're working with a file or object you recognize.

You might also consider writing macros for applications you know about and wish to support; those macros can react when the user decides to open a document and send a monitor program some notification.

But, the bottom line is that certainly isn't "another way" to know what actions an arbitrary application is performing.

B ekiM


0
 
therichardsonsAuthor Commented:
I think you may have misunderstood the question.  I don't car why the document was opened or who opened it.  I just need to have my app asked if it is OK to open this document.

I have used macros and an OLE embedding model to do this in the past but there are issues with embedding certain documents.
0
 
mikeblasCommented:
Then a VXD is your only viable solution.

B ekiM

0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now