本文整理汇总了C++中IPropertyStorage::Release方法的典型用法代码示例。如果您正苦于以下问题:C++ IPropertyStorage::Release方法的具体用法?C++ IPropertyStorage::Release怎么用?C++ IPropertyStorage::Release使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPropertyStorage
的用法示例。
在下文中一共展示了IPropertyStorage::Release方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetProperties
void App::GetProperties()
{
LPSTORAGE pStorage = NULL;
IPropertySetStorage* pPropertySetStorage = NULL;
IPropertyStorage* pSummaryInfoStorage = NULL;
IPropertyStorage* pDocumentSummaryInfoStorage = NULL;
IPropertyStorage* pUserDefinedPropertyStorage = NULL;
wchar_t wfilename[_MAX_PATH];
char szBuf[256];
char filename[MAX_PATH];
SendMessage(GetDlgItem(hPropDialog, IDC_TITLE), WM_SETTEXT, 0, (LPARAM)"");
SendMessage(GetDlgItem(hPropDialog, IDC_SUBJECT), WM_SETTEXT, 0, (LPARAM)"");
SendMessage(GetDlgItem(hPropDialog, IDC_AUTHOR), WM_SETTEXT, 0, (LPARAM)"");
SendMessage(GetDlgItem(hPropDialog, IDC_MANAGER), WM_SETTEXT, 0, (LPARAM)"");
SendMessage(GetDlgItem(hPropDialog, IDC_COMPANY), WM_SETTEXT, 0, (LPARAM)"");
SendMessage(GetDlgItem(hPropDialog, IDC_CATEGORY), WM_SETTEXT, 0, (LPARAM)"");
SendMessage(GetDlgItem(hPropDialog, IDC_KEYWORDS), WM_SETTEXT, 0, (LPARAM)"");
SendMessage(GetDlgItem(hPropDialog, IDC_COMMENTS), WM_SETTEXT, 0, (LPARAM)"");
SendMessage(GetDlgItem(hPropDialog, IDC_CONTENTS), LB_RESETCONTENT, 0, 0);
ListView_DeleteAllItems(GetDlgItem(hPropDialog, IDC_CUSTOM));
int idx = SendMessage(hListBox, LB_GETCURSEL, 0, 0);
SendMessage(hListBox, LB_GETTEXT, idx, (LPARAM)filename);
SetWindowText(hPropDialog, filename);
MultiByteToWideChar(CP_ACP, 0, filename, -1, wfilename, _MAX_PATH);
HRESULT res = StgOpenStorage(wfilename, (LPSTORAGE)0, STGM_DIRECT|STGM_READ|STGM_SHARE_EXCLUSIVE, NULL,0,&pStorage);
if (res!=S_OK) {
return;
}
// Get the Storage interface
if (S_OK != pStorage->QueryInterface(IID_IPropertySetStorage, (void**)&pPropertySetStorage)) {
pStorage->Release();
return;
}
// Get the SummaryInfo property set interface
if (S_OK == pPropertySetStorage->Open(FMTID_SummaryInformation, STGM_READ|STGM_SHARE_EXCLUSIVE, &pSummaryInfoStorage)) {
BOOL bFound = FALSE;
PROPSPEC PropSpec[5];
PROPVARIANT PropVar[5];
PropSpec[0].ulKind = PRSPEC_PROPID;
PropSpec[0].propid = PID_TITLE;
PropSpec[1].ulKind = PRSPEC_PROPID;
PropSpec[1].propid = PID_SUBJECT;
PropSpec[2].ulKind = PRSPEC_PROPID;
PropSpec[2].propid = PID_AUTHOR;
PropSpec[3].ulKind = PRSPEC_PROPID;
PropSpec[3].propid = PID_KEYWORDS;
PropSpec[4].ulKind = PRSPEC_PROPID;
PropSpec[4].propid = PID_COMMENTS;
HRESULT hr = pSummaryInfoStorage->ReadMultiple(5, PropSpec, PropVar);
if (S_OK == hr) {
if (PropVar[0].vt == VT_LPSTR) {
SendMessage(GetDlgItem(hPropDialog, IDC_TITLE), WM_SETTEXT, 0, (LPARAM)PropVar[0].pszVal);
}
if (PropVar[1].vt == VT_LPSTR) {
SendMessage(GetDlgItem(hPropDialog, IDC_SUBJECT), WM_SETTEXT, 0, (LPARAM)PropVar[1].pszVal);
}
if (PropVar[2].vt == VT_LPSTR) {
SendMessage(GetDlgItem(hPropDialog, IDC_AUTHOR), WM_SETTEXT, 0, (LPARAM)PropVar[2].pszVal);
}
if (PropVar[3].vt == VT_LPSTR) {
SendMessage(GetDlgItem(hPropDialog, IDC_KEYWORDS), WM_SETTEXT, 0, (LPARAM)PropVar[3].pszVal);
}
if (PropVar[4].vt == VT_LPSTR) {
SendMessage(GetDlgItem(hPropDialog, IDC_COMMENTS), WM_SETTEXT, 0, (LPARAM)PropVar[4].pszVal);
}
}
FreePropVariantArray(5, PropVar);
pSummaryInfoStorage->Release();
}
// Get the DocumentSummaryInfo property set interface
if (S_OK == pPropertySetStorage->Open(FMTID_DocSummaryInformation, STGM_READ|STGM_SHARE_EXCLUSIVE, &pDocumentSummaryInfoStorage)) {
BOOL bFound = FALSE;
PROPSPEC PropSpec[5];
PROPVARIANT PropVar[5];
PropSpec[0].ulKind = PRSPEC_PROPID;
PropSpec[0].propid = PID_MANAGER;
PropSpec[1].ulKind = PRSPEC_PROPID;
PropSpec[1].propid = PID_COMPANY;
PropSpec[2].ulKind = PRSPEC_PROPID;
//.........这里部分代码省略.........
示例2: Load
BOOL CDocFile::Load(TCHAR* wszFilePath)
{
IStorage *pStorage = NULL;
IPropertySetStorage *pPropSetStg = NULL;
IStream *pStream = NULL, *pTableStream = NULL;
HRESULT hr;
// Open the document as an OLE compound document.
hr = ::StgOpenStorage(wszFilePath, NULL,
STGM_READWRITE | STGM_SHARE_EXCLUSIVE, NULL, 0, &pStorage);
if(FAILED(hr)) {
_tprintf( L"A file is locked by another program: [%s]\n", wszFilePath);
return FALSE;
}
#ifdef CONTENT_EXTRACTION
hr = pStorage->OpenStream(L"WordDocument", NULL, STGM_READWRITE | STGM_SHARE_EXCLUSIVE, 0, &pStream);
if(FAILED(hr)) {
_tprintf( L"A file is invalid or damaged: [%s]\n", wszFilePath);
pStorage->Release();
return FALSE;
}
STATSTG stat;
pStream->Stat(&stat, 0);
UINT size = (UINT) stat.cbSize.QuadPart;
BYTE *buffer = new BYTE[size];
USHORT usFlag;
INT pdcOffset;
UINT pdcLength;
LARGE_INTEGER liTmpSeek;
ULONG cbRead;
liTmpSeek.QuadPart = 10;
pStream->Seek(liTmpSeek, 0, NULL);
pStream->Read(&usFlag, 2, &cbRead);
liTmpSeek.QuadPart = 418;
pStream->Seek(liTmpSeek, 0, NULL);
pStream->Read(&pdcOffset, 4, &cbRead);
pStream->Read(&pdcLength, 4, &cbRead);
hr = pStorage->OpenStream((usFlag & (0x1 << 9)) ? L"1Table" : L"0Table", NULL, STGM_READWRITE | STGM_SHARE_EXCLUSIVE, 0, &pTableStream);
liTmpSeek.QuadPart = pdcOffset;
pTableStream->Seek(liTmpSeek, 0, NULL);
INT nCount = 0;
INT *aOffsets = NULL;
struct Desc {
BYTE Flags;
BYTE Fn;
UINT32 Fc;
SHORT Prm;
} *aDescs = NULL;
UINT nPointer = 0;
while (nPointer < pdcLength)
{
BYTE nType = 0;
pTableStream->Read(&nType, 1, &cbRead);
switch(nType)
{
case 0:
BYTE nTmp;
pTableStream->Read(&nTmp, 1, &cbRead);
nPointer++;
break;
case 1:
{
SHORT cbGrpprl;
BYTE *grpprlData = NULL;
pTableStream->Read(&cbGrpprl, 2, &cbRead);
nPointer+=2;
grpprlData = new BYTE[cbGrpprl];
pTableStream->Read(grpprlData, cbGrpprl, &cbRead);
nPointer+=cbGrpprl;
delete grpprlData;
break;
}
case 2:
INT nTableLen = 0;
pTableStream->Read(&nTableLen, 4, &cbRead);
nPointer+=4;
nCount = (nTableLen - 4) / (8 + 4) + 1;
aOffsets = new INT[nCount];
for(int i = 0; i < nCount; i++) {
pTableStream->Read(&aOffsets[i], 4, &cbRead);
nPointer +=4;
}
aDescs = new Desc[nCount-1];
for(int i = 0; i < nCount-1; i++) {
pTableStream->Read(&aDescs[i].Flags, 1, &cbRead);
pTableStream->Read(&aDescs[i].Fn, 1, &cbRead);
pTableStream->Read(&aDescs[i].Fc, 4, &cbRead);
pTableStream->Read(&aDescs[i].Prm, 2, &cbRead);
nPointer+=sizeof(struct Desc);
}
//.........这里部分代码省略.........