Check if a Memory Buffer Contain Structured Storage File Data

82 views Asked by At

I need to check if a in memory buffer BYTE* lpBuf contain data of a stucture storage file data.

Currently I save the buffer data into a temp file, then use StgOpenStorage to open the file. If the open succeeds, then the file is a structured storage file, otherwise it is not.

CFile File;

if (File.Open(_T("E:\\Myfile.dat"), CFile::modeCreate | CFile::modeRead)
{
  File.Write(lpBuf, uBufSize);
  File.Close();
}

LPSTORAGE lpStorageFile = NULL;

HRESULT hr = StgOpenStorage(_T("E:\\Myfile.dat"), NULL, STGM_TRANSACTED | STGM_READ | STGM_SHARE_EXCLUSIVE, NULL, 0, &lpStorageFile);

return SUCCEED(hr);

Is there any easy way to do the task?

Thanks

0

There are 0 answers