Exclusive visio file access

N

nbelyh

I need to protect Visio files from being accessed from outside of
Visio while they are edited in Visio.
(In our solution, normally, visio files are stored in database, but
for editing, they are pulled out)

The options I can imagine:

1. Create a temporary file, work with it, delte after working.
The problem with this approach is, how do I make visio block file for
exclusive access?
That is, I'd want to deny reading for all other processes while the
file is open in Visio.
Unfortunately, OpenEx does not have a flag "exclusive access"...
And fighting this seem to sound as bad as API hooking (CreateFile
function),
or discovering file handle with ZwQueryInformation to change file
share mode to exclusive.
Or there is a plain solution I missed?

2. Creating a named pipe and passing Visio a path to it (Will it work?
Can visio read named pipes?)
I.e. does Visio use "seek" to read files, or it just reads it
sequentially?

3. Creating special folder for temporary files, accessible for only
one user (created on setup), and impersonating current thread as this
user when doing file operations (before calling OpenEx, SaveAs,
etc)... Can it work?

Any advises or comments are greately appreciated.... :)
 
C

Chris Roth [MVP]

Hi NB,

It looks to me like Visio locks a file when it is "opened as original"
anyway. If I try to open an already-opened file, say in a second instance of
Visio, I get the error message:

"Runtime error: blah blah blah"
"The file is open for modifications in another instance of Visio."

--
Hope this helps,

Chris Roth
Visio MVP

Free Visio shapes:
http://www.visguy.com/category/shapes
Visio programming info:
http://www.visguy.com/category/programming/
Other Visio resources:
http://www.visguy.com/visio-links/
 
N

nbelyh

Hi Chris.
It looks to me like Visio locks a file when it is "opened as original"
anyway. If I try to open an already-opened file, say in a second instance of
Visio, I get the error message:

"Runtime error: blah blah blah"
"The file is open for modifications in another instance of Visio."

Nope ;)
Visio blocks only writing to opened files. But it still allows read.
I.e. visio opens file non-exclusively.
This can be proven by trying to copy opened file (using windows
explorer for example) - it works.

Regards, Nikolay.
 
C

Chris Roth [MVP]

N

nbelyh

Oh, I see what you mean! You are doing something hard-core!

Give the temp file a filename that is a GUID, so that no other app would
ever guess that the file is there??? : ) I am wondering what app would try
to copy your temp file....

Of course applications won't. Users would. ;)
The point is, the diagram protection. We'd want to prevent users from
copying (some) diagrams (reference model diagrams) entirely. The only
thing users shall be allowed to do with such "protected" diagrams is
editing them in Visio (when our visio addin is installed). Ideally,
we'd want to have no file on disk at all... I.e. stream the diagram
from the database into memory buffer, and then make visio open that
buffer. But unfortunately Visio seems to works with files only...
And here we come to the problem and the approaches 1,2,3 ...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top