⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 propstgenum.h

📁 CD刻录,含有源代码,好东西大家分享哈.互相交流学习.
💻 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 + -