n***@cox.net
2005-09-13 22:01:43 UTC
If I open a document, close it, then open it again, the document is
opened in "read only" mode.
OleDoc1.cpp, lines 497+ (Microsoft)
// open new storage file
sc = StgOpenStorage(lpsz, NULL,
STGM_READWRITE|STGM_TRANSACTED|STGM_SHARE_DENY_WRITE,
0, 0, &lpStorage);
if (FAILED(sc) || lpStorage == NULL)
sc = StgOpenStorage(lpsz, NULL,
STGM_READ|STGM_TRANSACTED, 0, 0, &lpStorage);
The first call to StgOpenStorage() with STGM_READWRITE succeeds when I
open a document after the application has started. But if I save a
document, close it, then open it again, the call to StgOpenStorage()
fails with STG_E_LOCKVIOLATION. I determined the error by copying the
lines from OleDoc1.cpp to my OnOpenDocument() command, and exercising
the code to find the error.
Since the first call to StgOpenStorage() fails, the next call succeeds,
but the file is opened "read only" since the STGM_READ flag is set. But
I can't save the document!
My OnCloseDocument() method calls COleServerDoc::OnCloseDocument();
which eventually releases the storage, line 654 of Ole1Doc1.cpp:
RELEASE(m_lpRootStg);
So why is the open call failing with STG_E_LOCKVIOLATION?
The storage is CLOSED, so I should be able to open it in read/write
mode.
Please help!
Thanks,
Chris
opened in "read only" mode.
OleDoc1.cpp, lines 497+ (Microsoft)
// open new storage file
sc = StgOpenStorage(lpsz, NULL,
STGM_READWRITE|STGM_TRANSACTED|STGM_SHARE_DENY_WRITE,
0, 0, &lpStorage);
if (FAILED(sc) || lpStorage == NULL)
sc = StgOpenStorage(lpsz, NULL,
STGM_READ|STGM_TRANSACTED, 0, 0, &lpStorage);
The first call to StgOpenStorage() with STGM_READWRITE succeeds when I
open a document after the application has started. But if I save a
document, close it, then open it again, the call to StgOpenStorage()
fails with STG_E_LOCKVIOLATION. I determined the error by copying the
lines from OleDoc1.cpp to my OnOpenDocument() command, and exercising
the code to find the error.
Since the first call to StgOpenStorage() fails, the next call succeeds,
but the file is opened "read only" since the STGM_READ flag is set. But
I can't save the document!
My OnCloseDocument() method calls COleServerDoc::OnCloseDocument();
which eventually releases the storage, line 654 of Ole1Doc1.cpp:
RELEASE(m_lpRootStg);
So why is the open call failing with STG_E_LOCKVIOLATION?
The storage is CLOSED, so I should be able to open it in read/write
mode.
Please help!
Thanks,
Chris