?? propstgenum.h
字號:
////////////////////////////////////////////////////////////////
// MSDN Magazine -- April 2004
// If this code works, it was written by Paul DiLascia.
// If not, I don't know who wrote it.
// Compiles with Visual Studio .NET on Windows XP. Tab size=3.
//
// To use:
//
// CPropertyStorageIterator it(pstg);
// CComVariant val;
// while (it.Next(val)) {
// // it.GetPropName() returns property name
// // it.GetPropid() returns property id
// // val contains value
// ... do something
// }
//
#pragma once
class CPropertyStorageIterator : public CComQIPtr<IEnumSTATPROPSTG>
{
protected:
IPropertyStorage* m_pstg; // property storage interface
STATPROPSTG m_statpropstg; // holds prop name, id
public:
HRESULT m_hr; // current return code
CPropertyStorageIterator(IPropertyStorage* pstg) : m_pstg(pstg) {
pstg->Enum(&p);
}
~CPropertyStorageIterator() { }
// get current property name/id
LPWSTR GetPropName() { return m_statpropstg.lpwstrName; }
PROPID GetPropid() { return m_statpropstg.propid; }
// navigatge to next property; fills val with value
BOOL Next(VARIANT& val) {
m_hr = (*this)->Next(1,&m_statpropstg,NULL);
if (m_hr==S_OK) {
PROPSPEC ps;
ps.ulKind = PRSPEC_PROPID;
ps.propid = m_statpropstg.propid;
m_hr = m_pstg->ReadMultiple(1,&ps,(PROPVARIANT*)&val);
return SUCCEEDED(m_hr);
}
return FALSE;
}
// dumb wrappers for IEnumSTATPROPSTG
BOOL Skip(ULONG n) { return SUCCEEDED((*this)->Skip(n)); }
BOOL Reset() { return SUCCEEDED((*this)->Reset()); }
};
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -