Hi,
The partail code below is used to generate the compound file
STDMETHODIMP CProject::SaveCompound(BSTR FileName)
{
CComPtr<IStorage> pRootStorage;
if (StgIsStorageFile(FileName) == S_OK)
{
_RTVH(StgOpenStorage(FileName, NULL, STGM_DIRECT | STGM_READWRITE |
STGM_SHARE_EXCLUSIVE, NULL, 0, &pRootStorage));
}
else
{
_RTVH(StgCreateDocfile(FileName, STGM_DIRECT | STGM_READWRITE |
STGM_CREATE | STGM_SHARE_EXCLUSIVE, 0, &pRootStorage));
}
CComPtr<IPersistStorage> pPersistStorage;
_RTVH(QueryInterface(IID_IPersistStorage,
reinterpret_cast<void**>(&pPersistStorage)));
_RTVH(pPersistStorage->Save(pRootStorage, FALSE));
return S_OK;
}
HRESULT CProject::Save(IStorage* pStorage, BOOL fSameAsLoad)
{
CComPtr<IStorage> pProjectStorage;
_RTVH(pStorage->CreateStorage(OLESTR("IProject"), STGM_DIRECT |
STGM_READWRITE | STGM_CREATE | STGM_SHARE_EXCLUSIVE, 0,0,
&pProjectStorage));
CComPtr<IStream> pStream;
_RTVH(pProjectStorage->CreateStream(OLESTR("Contents"), STGM_DIRECT |
STGM_READWRITE | STGM_CREATE | STGM_SHARE_EXCLUSIVE, 0,0, &pStream));
CComPtr<IPersistStreamInit> pPersistStreamInit;
_RTVH(QueryInterface(IID_IPersistStreamInit,
reinterpret_cast<void**>(&pPersistStreamInit)));
_RTVH(pPersistStreamInit->Save(pStream, FALSE));
return S_OK;
}
HRESULT CProject::Save(LPSTREAM pStm, BOOL fClearDirty)
{
ULONG lWrite;
_RTVH(m_bstrVersion.WriteToStream(pStm));
_RTVH(m_bstrDescription.WriteToStream(pStm));
_RTVH(m_bstrShortDescription.WriteToStream(pStm));
_RTVH(m_bstrOwner.WriteToStream(pStm));
_RTVH(pStm->Write((void*)&m_eInterpolationMethod,
sizeof(m_eInterpolationMethod), &lWrite));
_RTVF(lWrite != sizeof(m_eInterpolationMethod));
....
}
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> a
écrit dans le message de news:On*************@tk2msftngp13.phx.gbl...
HI,
I think that depends of the document itself, in .net you can read a
binary file so in principle you can recreate the same structure. it's up the app
to interprete the bytes properly though.
How was the document created?
cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Polo" <pb@rtech.be> wrote in message
news:43**********************@news.skynet.be... Hi,
We developped an application that save files as a compound document.
Now we developp a new version in net and we would like to import old
file format. What is the best way. A sample or a link is welcome
Thank's in advance
Polo