@@@@亟待解决:读写文件摘要的问题!!!!!!!!
一般的文件都有文件摘要属性页,它包括了作者、标题、评论等内容。我在VC下用以下代码实现了除了图片文件以外的其他文件的文件摘要信息的写入。执行完毕后,如果是非bmp、jpg等图片文件,那么在文件的右键属性页中出现刚才写入的摘要信息。但是图片文件不显示摘要信息。
而且,此时如果,把文件的后缀名改为其他的,比如“.txt”,摘要信息就看得到了。这个是为什么呢?
请高手相助,很急啊!!!!!!!!!!!!!!!!!!!!!!!!!!
IPropertySetStorage *pPropSetStg = NULL;
IPropertyStorage *pPropStg = NULL;
PROPSPEC propspec[4];
PROPVARIANT propWrite[4];
HRESULT hr = S_OK;
USES_CONVERSION;
hr = StgOpenStorageEx( szFilePath,
STGM_DIRECT |STGM_SHARE_EXCLUSIVE|STGM_READWRITE,
STGFMT_ANY,
0,
NULL,
NULL,
IID_IPropertySetStorage,
reinterpret_cast<void**>(&pPropSetStg) );
DWORD Result = 0;
if( FAILED(hr) )
{
Result = GetLastError();
return; // if not ntfs , it will be error.
throw L"Failed StgOpenStorageEx";
}
hr = pPropSetStg->Create( FMTID_SummaryInformation, NULL, PROPSETFLAG_DEFAULT,
STGM_CREATE|STGM_READWRITE|STGM_SHARE_EXCLUSIVE,
&pPropStg );
if( FAILED(hr) )
throw L"Failed IPropertySetStorage::Open";
//we can identify any property through its Name or its ID
// propspec.ulKind = PRSPEC_LPWSTR;
// propspec.lpwstr = L"Title";
propspec[0].ulKind = PRSPEC_PROPID;
propspec[0].propid = 0x00000002;
propWrite[0].vt = VT_LPWSTR;
propWrite[0].pwszVal = LPTSTR(LPCTSTR(szTitle));
propspec[1].ulKind = PRSPEC_PROPID;
propspec[1].propid = 0x00000003;
propWrite[1].vt = VT_LPWSTR;
propWrite[1].pwszVal = LPTSTR(LPCTSTR(szSubject));
propspec[2].ulKind = PRSPEC_PROPID;
propspec[2].propid = 0x00000004;
propWrite[2].vt = VT_LPWSTR;
propWrite[2].pwszVal = LPTSTR(LPCTSTR(szAuthor));
propspec[3].ulKind = PRSPEC_PROPID;
propspec[3].propid = 0x00000006;
propWrite[3].vt = VT_LPWSTR;
propWrite[3].pwszVal = LPTSTR(LPCTSTR(szComment));
hr = pPropStg->WriteMultiple(4, propspec, propWrite, PID_DICTIONARY);
if( FAILED(hr) )
throw L"Failed IPropertyStorage::WriteMultiple";
pPropStg->Release();
pPropStg = NULL;
pPropSetStg->Release();
pPropSetStg = NULL;