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
|
#include "RenderingInformationFakeContent.h.tmh"
class RenderingInformationFakeContent : public FakeContent
{
public:
RenderingInformationFakeContent()
{
}
RenderingInformationFakeContent(const RenderingInformationFakeContent& src)
{
*this = src;
}
virtual ~RenderingInformationFakeContent()
{
}
virtual HRESULT GetSupportedProperties(_COM_Outptr_ IPortableDeviceKeyCollection** ppKeys)
{
HRESULT hr = S_OK;
if(ppKeys == NULL)
{
hr = E_POINTER;
CHECK_HR(hr, "Cannot have NULL collection parameter");
return hr;
}
*ppKeys = NULL;
if (SUCCEEDED(hr))
{
hr = AddSupportedProperties(WPD_FUNCTIONAL_CATEGORY_RENDERING_INFORMATION, ppKeys);
CHECK_HR(hr, "Failed to add additional properties for RenderingInformationFakeContent");
}
return hr;
}
virtual HRESULT GetAllValues(
_In_ IPortableDeviceValues* pStore)
{
HRESULT hr = S_OK;
HRESULT hrSetValue = S_OK;
if(pStore == NULL)
{
hr = E_POINTER;
CHECK_HR(hr, "Cannot have NULL parameter");
return hr;
}
// Call the base class to fill in the standard properties
hr = FakeContent::GetAllValues(pStore);
if (FAILED(hr))
{
CHECK_HR(hr, "Failed to get basic property set");
return hr;
}
// Add WPD_FUNCTIONAL_OBJECT_CATEGORY
hrSetValue = pStore->SetGuidValue(WPD_FUNCTIONAL_OBJECT_CATEGORY, WPD_FUNCTIONAL_CATEGORY_RENDERING_INFORMATION);
if (hrSetValue != S_OK)
{
CHECK_HR(hr, "Failed to set WPD_FUNCTIONAL_OBJECT_CATEGORY");
return hrSetValue;
}
// Add WPD_RENDERING_INFORMATION_PROFILES
hrSetValue = SetRenderingProfiles(pStore);
if (hrSetValue != S_OK)
{
CHECK_HR(hrSetValue, ("Failed to set WPD_RENDERING_INFORMATION_PROFILES"));
return hrSetValue;
}
return hr;
}
virtual HRESULT GetAttributes(
_In_ REFPROPERTYKEY Key,
_COM_Outptr_ IPortableDeviceValues** ppAttributes)
{
HRESULT hr = S_OK;
CComPtr<IPortableDeviceValues> pAttributes;
if(ppAttributes == NULL)
{
hr = E_POINTER;
CHECK_HR(hr, "Cannot have NULL attributes parameter");
return hr;
}
*ppAttributes = NULL;
if (SUCCEEDED(hr))
{
hr = CoCreateInstance(CLSID_PortableDeviceValues,
NULL,
CLSCTX_INPROC_SERVER,
IID_IPortableDeviceValues,
(VOID**) &pAttributes);
CHECK_HR(hr, "Failed to CoCreate CLSID_PortableDeviceValues");
}
if (SUCCEEDED(hr))
{
hr = AddFixedPropertyAttributes(WPD_FUNCTIONAL_CATEGORY_RENDERING_INFORMATION, Key, pAttributes);
CHECK_HR(hr, "Failed to add fixed property attributes for %ws.%d on RenderingInformationFakeContent", CComBSTR(Key.fmtid), Key.pid);
}
// Some of our properties have extra attributes on top of the ones that are common to all
if(IsEqualPropertyKey(Key, WPD_OBJECT_NAME))
{
CAtlStringW strDefaultName;
strDefaultName.Format(L"%ws%ws", L"Name", ObjectID.GetString());
hr = pAttributes->SetStringValue(WPD_PROPERTY_ATTRIBUTE_DEFAULT_VALUE, strDefaultName.GetString());;
CHECK_HR(hr, "Failed to set WPD_PROPERTY_ATTRIBUTE_DEFAULT_VALUE");
}
// Return the property attributes
if (SUCCEEDED(hr))
{
hr = pAttributes->QueryInterface(IID_IPortableDeviceValues, (VOID**) ppAttributes);
CHECK_HR(hr, "Failed to QI for IPortableDeviceValues on Wpd IPortableDeviceValues");
}
return hr;
}
virtual GUID GetObjectFormat()
{
return WPD_OBJECT_FORMAT_UNSPECIFIED;
}
};
|