This repository has been archived by the owner on Dec 28, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathShellItemArray.hpp
142 lines (114 loc) · 4.01 KB
/
ShellItemArray.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/* ShellItemArray.hpp --- v2xol.dll for vista2xp */
/* This file is public domain software.
Copyright (C) 2019 Katayama Hirofumi MZ <[email protected]>. */
#ifndef SHELL_ITEM_ARRAY_HPP_
#define SHELL_ITEM_ARRAY_HPP_
#include <windows.h>
#include <objbase.h>
#include <shobjidl.h>
class MEnumShellItems;
class MShellItemArray;
BOOL _ILIsDesktop(LPCITEMIDLIST pidl);
HRESULT STDAPICALLTYPE
SHCreateShellItemForXP0(
PCIDLIST_ABSOLUTE pidlParent,
IShellFolder *psfParent,
PCUITEMID_CHILD pidl,
IShellItem **ppsi);
HRESULT STDAPICALLTYPE
SHGetNameFromIDListForXP0(PCIDLIST_ABSOLUTE pidl, SIGDN sigdnName, PWSTR *ppszName);
///////////////////////////////////////////////////////////////////////////////
class MShellItem : public IShellItem, public IPersistIDList
{
public:
static MShellItem *CreateInstance();
static MShellItem *CreateInstance(LPITEMIDLIST pidl);
// IUnknown interface
STDMETHODIMP QueryInterface(REFIID riid, void **ppvObject);
STDMETHODIMP_(ULONG) AddRef();
STDMETHODIMP_(ULONG) Release();
// IShellItem interface
STDMETHODIMP BindToHandler(IBindCtx *pbc, REFGUID rbhid, REFIID riid, void **ppvOut);
STDMETHODIMP GetParent(IShellItem **ppsi);
STDMETHODIMP GetDisplayName(SIGDN sigdnName, LPWSTR *ppszName);
STDMETHODIMP GetAttributes(SFGAOF sfgaoMask, SFGAOF *psfgaoAttribs);
STDMETHODIMP Compare(IShellItem *oth, SICHINTF hint, int *piOrder);
// IPersistIDList interface
STDMETHODIMP GetClassID(CLSID *pClassID);
STDMETHODIMP SetIDList(LPCITEMIDLIST pidl);
STDMETHODIMP GetIDList(LPITEMIDLIST *ppidl);
HRESULT get_parent_pidl(LPITEMIDLIST *parent_pidl);
HRESULT get_parent_shellfolder(IShellFolder **ppsf);
HRESULT get_shellfolder(IBindCtx *pbc, REFIID riid, void **ppvOut);
protected:
LONG m_nRefCount;
LPITEMIDLIST m_pidl;
MShellItem();
MShellItem(LPITEMIDLIST pidl);
virtual ~MShellItem();
};
///////////////////////////////////////////////////////////////////////////////
class MEnumShellItems : public IEnumShellItems
{
public:
static MEnumShellItems *CreateInstance(IShellItemArray *array);
// IUnknown interface
STDMETHODIMP QueryInterface(REFIID riid, void **ppvObject);
STDMETHODIMP_(ULONG) AddRef();
STDMETHODIMP_(ULONG) Release();
// IEnumShellItems interface
STDMETHODIMP Next(
ULONG celt,
IShellItem **rgelt,
ULONG *pceltFetched);
STDMETHODIMP Skip(ULONG celt);
STDMETHODIMP Reset();
STDMETHODIMP Clone(IEnumShellItems **ppenum);
protected:
LONG m_nRefCount;
IShellItemArray *m_pArray;
DWORD m_dwIndex;
DWORD m_dwCount;
MEnumShellItems(IShellItemArray *array);
virtual ~MEnumShellItems();
};
///////////////////////////////////////////////////////////////////////////////
class MShellItemArray : public IShellItemArray
{
public:
static MShellItemArray *CreateInstance();
HRESULT AddItem(IShellItem *pItem);
// IUnknown interface
STDMETHODIMP QueryInterface(REFIID riid, void **ppvObject);
STDMETHODIMP_(ULONG) AddRef();
STDMETHODIMP_(ULONG) Release();
// IShellItemArray interface
STDMETHODIMP BindToHandler(
IBindCtx *pbc,
REFGUID bhid,
REFIID riid,
void **ppvOut);
STDMETHODIMP GetPropertyStore(
GETPROPERTYSTOREFLAGS flags,
REFIID riid,
void **ppv);
STDMETHODIMP GetPropertyDescriptionList(
REFPROPERTYKEY keyType,
REFIID riid,
void **ppv);
STDMETHODIMP GetAttributes(
SIATTRIBFLAGS AttribFlags,
SFGAOF sfgaoMask,
SFGAOF *psfgaoAttribs);
STDMETHODIMP GetCount(DWORD *pdwNumItems);
STDMETHODIMP GetItemAt(DWORD dwIndex, IShellItem **ppsi);
STDMETHODIMP EnumItems(IEnumShellItems **ppenumShellItems);
protected:
LONG m_nRefCount;
ULONG m_nItemCount;
IShellItem **m_pItems;
MShellItemArray();
virtual ~MShellItemArray();
};
///////////////////////////////////////////////////////////////////////////////
#endif // ndef SHELL_ITEM_ARRAY_HPP_