-
Notifications
You must be signed in to change notification settings - Fork 200
/
Copy pathShObjIdl.IPersistFolder.cs
415 lines (400 loc) · 23.5 KB
/
ShObjIdl.IPersistFolder.cs
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
using System;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
using static Vanara.PInvoke.Ole32;
namespace Vanara.PInvoke
{
public static partial class Shell32
{
/// <summary>Exposes a method that initializes Shell folder objects.</summary>
/// <remarks>
/// <para>
/// When you implement a Shell namespace extension, specifically the IShellFolder interface, you must implement this interface so
/// the folder object can be initialized. Implementation of this interface is how the folder is told where it is in the Shell namespace.
/// </para>
/// <para>
/// You do not use this interface directly. It is used by the file system implementation of the IShellFolder::BindToObject interface
/// when it is initializing a Shell folder object.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nn-shobjidl_core-ipersistfolder
[PInvokeData("shobjidl_core.h", MSDNShortId = "NN:shobjidl_core.IPersistFolder")]
[ComImport, Guid("000214EA-0000-0000-C000-000000000046"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IPersistFolder : IPersist
{
/// <summary>Retrieves the class identifier (CLSID) of the object.</summary>
/// <returns>
/// <para>
/// A pointer to the location that receives the CLSID on return. The CLSID is a globally unique identifier (GUID) that uniquely
/// represents an object class that defines the code that can manipulate the object's data.
/// </para>
/// <para>If the method succeeds, the return value is S_OK. Otherwise, it is E_FAIL.</para>
/// </returns>
/// <remarks>
/// <para>
/// The <c>GetClassID</c> method retrieves the class identifier (CLSID) for an object, used in later operations to load
/// object-specific code into the caller's context.
/// </para>
/// <para>Notes to Callers</para>
/// <para>
/// A container application might call this method to retrieve the original CLSID of an object that it is treating as a
/// different class. Such a call would be necessary if a user performed an editing operation that required the object to be
/// saved. If the container were to save it using the treat-as CLSID, the original application would no longer be able to edit
/// the object. Typically, in this case, the container calls the OleSave helper function, which performs all the necessary
/// steps. For this reason, most container applications have no need to call this method directly.
/// </para>
/// <para>
/// The exception would be a container that provides an object handler for certain objects. In particular, a container
/// application should not get an object's CLSID and then use it to retrieve class specific information from the registry.
/// Instead, the container should use IOleObject and IDataObject interfaces to retrieve such class-specific information directly
/// from the object.
/// </para>
/// <para>Notes to Implementers</para>
/// <para>
/// Typically, implementations of this method simply supply a constant CLSID for an object. If, however, the object's
/// <c>TreatAs</c> registry key has been set by an application that supports emulation (and so is treating the object as one of
/// a different class), a call to <c>GetClassID</c> must supply the CLSID specified in the <c>TreatAs</c> key. For more
/// information on emulation, see CoTreatAsClass.
/// </para>
/// <para>
/// When an object is in the running state, the default handler calls an implementation of <c>GetClassID</c> that delegates the
/// call to the implementation in the object. When the object is not running, the default handler instead calls the ReadClassStg
/// function to read the CLSID that is saved in the object's storage.
/// </para>
/// <para>
/// If you are writing a custom object handler for your object, you might want to simply delegate this method to the default
/// handler implementation (see OleCreateDefaultHandler).
/// </para>
/// <para>URL Moniker Notes</para>
/// <para>This method returns CLSID_StdURLMoniker.</para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/objidl/nf-objidl-ipersist-getclassid HRESULT GetClassID( CLSID *pClassID );
new Guid GetClassID();
/// <summary>Instructs a Shell folder object to initialize itself based on the information passed.</summary>
/// <param name="pidl">
/// <para>Type: <c>LPCITEMIDLIST</c></para>
/// <para>The address of the ITEMIDLIST (item identifier list) structure that specifies the absolute location of the folder.</para>
/// </param>
/// <remarks>
/// <para>
/// All objects that implement the IShellFolder interface for use in the Shell's namespace must implement this method. When a
/// folder's location in the namespace is not a relevant consideration, this method can simply return S_OK. When the location is
/// relevant to the folder, you should store the fully qualified IDLIST passed in for later reference.
/// </para>
/// <para>
/// For example, if the folder implementation needs to construct a fully qualified pointer to an item identifier list (PIDL) to
/// elements that it contains, the PIDL passed to this method should be used to construct the fully qualified PIDLs.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-ipersistfolder-initialize HRESULT
// Initialize( PCIDLIST_ABSOLUTE pidl );
void Initialize([In] PIDL pidl);
}
/// <summary>Exposes methods that obtain information from Shell folder objects.</summary>
/// <remarks>
/// <para>This interface also provides the methods of the IPersist, IPersistFolder interfaces, from which it inherits.</para>
/// <para>When to Implement</para>
/// <para>
/// When implementing a Shell namespace extension, specifically the IShellFolder interface, you need to implement this interface so
/// that the Shell folder object's ITEMIDLIST can be retrieved.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nn-shobjidl_core-ipersistfolder2
[PInvokeData("shobjidl_core.h", MSDNShortId = "NN:shobjidl_core.IPersistFolder2")]
[ComImport, Guid("1AC3D9F0-175C-11d1-95BE-00609797EA4F"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IPersistFolder2 : IPersistFolder
{
/// <summary>Retrieves the class identifier (CLSID) of the object.</summary>
/// <returns>
/// <para>
/// A pointer to the location that receives the CLSID on return. The CLSID is a globally unique identifier (GUID) that uniquely
/// represents an object class that defines the code that can manipulate the object's data.
/// </para>
/// <para>If the method succeeds, the return value is S_OK. Otherwise, it is E_FAIL.</para>
/// </returns>
/// <remarks>
/// <para>
/// The <c>GetClassID</c> method retrieves the class identifier (CLSID) for an object, used in later operations to load
/// object-specific code into the caller's context.
/// </para>
/// <para>Notes to Callers</para>
/// <para>
/// A container application might call this method to retrieve the original CLSID of an object that it is treating as a
/// different class. Such a call would be necessary if a user performed an editing operation that required the object to be
/// saved. If the container were to save it using the treat-as CLSID, the original application would no longer be able to edit
/// the object. Typically, in this case, the container calls the OleSave helper function, which performs all the necessary
/// steps. For this reason, most container applications have no need to call this method directly.
/// </para>
/// <para>
/// The exception would be a container that provides an object handler for certain objects. In particular, a container
/// application should not get an object's CLSID and then use it to retrieve class specific information from the registry.
/// Instead, the container should use IOleObject and IDataObject interfaces to retrieve such class-specific information directly
/// from the object.
/// </para>
/// <para>Notes to Implementers</para>
/// <para>
/// Typically, implementations of this method simply supply a constant CLSID for an object. If, however, the object's
/// <c>TreatAs</c> registry key has been set by an application that supports emulation (and so is treating the object as one of
/// a different class), a call to <c>GetClassID</c> must supply the CLSID specified in the <c>TreatAs</c> key. For more
/// information on emulation, see CoTreatAsClass.
/// </para>
/// <para>
/// When an object is in the running state, the default handler calls an implementation of <c>GetClassID</c> that delegates the
/// call to the implementation in the object. When the object is not running, the default handler instead calls the ReadClassStg
/// function to read the CLSID that is saved in the object's storage.
/// </para>
/// <para>
/// If you are writing a custom object handler for your object, you might want to simply delegate this method to the default
/// handler implementation (see OleCreateDefaultHandler).
/// </para>
/// <para>URL Moniker Notes</para>
/// <para>This method returns CLSID_StdURLMoniker.</para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/objidl/nf-objidl-ipersist-getclassid HRESULT GetClassID( CLSID *pClassID );
new Guid GetClassID();
/// <summary>Instructs a Shell folder object to initialize itself based on the information passed.</summary>
/// <param name="pidl">
/// <para>Type: <c>LPCITEMIDLIST</c></para>
/// <para>The address of the ITEMIDLIST (item identifier list) structure that specifies the absolute location of the folder.</para>
/// </param>
/// <remarks>
/// <para>
/// All objects that implement the IShellFolder interface for use in the Shell's namespace must implement this method. When a
/// folder's location in the namespace is not a relevant consideration, this method can simply return S_OK. When the location is
/// relevant to the folder, you should store the fully qualified IDLIST passed in for later reference.
/// </para>
/// <para>
/// For example, if the folder implementation needs to construct a fully qualified pointer to an item identifier list (PIDL) to
/// elements that it contains, the PIDL passed to this method should be used to construct the fully qualified PIDLs.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-ipersistfolder-initialize HRESULT
// Initialize( PCIDLIST_ABSOLUTE pidl );
new void Initialize([In] PIDL pidl);
/// <summary>Gets the ITEMIDLIST for the folder object.</summary>
/// <param name="ppidl">
/// <para>Type: <c>LPITEMIDLIST*</c></para>
/// <para>
/// The address of an ITEMIDLIST pointer. This PIDL represents the absolute location of the folder and must be relative to the
/// desktop. This is typically a copy of the PIDL passed to Initialize.
/// </para>
/// </param>
/// <returns>
/// <para>Type: <c>HRESULT</c></para>
/// <para>If this method succeeds, it returns <c>S_OK</c>. Otherwise, it returns an <c>HRESULT</c> error code.</para>
/// </returns>
/// <remarks>If the folder object has not been initialized, this method returns S_FALSE and ppidl is set to <c>NULL</c>.</remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-ipersistfolder2-getcurfolder HRESULT
// GetCurFolder( PIDLIST_ABSOLUTE *ppidl );
[PreserveSig]
HRESULT GetCurFolder(ref PIDL ppidl);
}
/// <summary>
/// Extends the IPersistFolder and IPersistFolder2 interfaces by allowing a folder object to implement nondefault handling of folder shortcuts.
/// </summary>
/// <remarks>
/// <para>
/// This interface also provides the methods of the IPersist, IPersistFolder, and IPersistFolder2 interfaces, from which it inherits.
/// </para>
/// <para>In Windows versions earlier than Windows Vista, this interface was declared in Shlobj.h.</para>
/// <para>When to Implement</para>
/// <para>Namespace extensions implement this interface if they need to perform nondefault handling of folder shortcuts.</para>
/// <para>When to Use</para>
/// <para>Applications do not normally use this interface directly.</para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nn-shobjidl_core-ipersistfolder3
[ComImport, Guid("CEF04FDF-FE72-11d2-87A5-00C04F6837CF"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IPersistFolder3 : IPersistFolder2
{
/// <summary>Retrieves the class identifier (CLSID) of the object.</summary>
/// <returns>
/// <para>
/// A pointer to the location that receives the CLSID on return. The CLSID is a globally unique identifier (GUID) that uniquely
/// represents an object class that defines the code that can manipulate the object's data.
/// </para>
/// <para>If the method succeeds, the return value is S_OK. Otherwise, it is E_FAIL.</para>
/// </returns>
/// <remarks>
/// <para>
/// The <c>GetClassID</c> method retrieves the class identifier (CLSID) for an object, used in later operations to load
/// object-specific code into the caller's context.
/// </para>
/// <para>Notes to Callers</para>
/// <para>
/// A container application might call this method to retrieve the original CLSID of an object that it is treating as a
/// different class. Such a call would be necessary if a user performed an editing operation that required the object to be
/// saved. If the container were to save it using the treat-as CLSID, the original application would no longer be able to edit
/// the object. Typically, in this case, the container calls the OleSave helper function, which performs all the necessary
/// steps. For this reason, most container applications have no need to call this method directly.
/// </para>
/// <para>
/// The exception would be a container that provides an object handler for certain objects. In particular, a container
/// application should not get an object's CLSID and then use it to retrieve class specific information from the registry.
/// Instead, the container should use IOleObject and IDataObject interfaces to retrieve such class-specific information directly
/// from the object.
/// </para>
/// <para>Notes to Implementers</para>
/// <para>
/// Typically, implementations of this method simply supply a constant CLSID for an object. If, however, the object's
/// <c>TreatAs</c> registry key has been set by an application that supports emulation (and so is treating the object as one of
/// a different class), a call to <c>GetClassID</c> must supply the CLSID specified in the <c>TreatAs</c> key. For more
/// information on emulation, see CoTreatAsClass.
/// </para>
/// <para>
/// When an object is in the running state, the default handler calls an implementation of <c>GetClassID</c> that delegates the
/// call to the implementation in the object. When the object is not running, the default handler instead calls the ReadClassStg
/// function to read the CLSID that is saved in the object's storage.
/// </para>
/// <para>
/// If you are writing a custom object handler for your object, you might want to simply delegate this method to the default
/// handler implementation (see OleCreateDefaultHandler).
/// </para>
/// <para>URL Moniker Notes</para>
/// <para>This method returns CLSID_StdURLMoniker.</para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/desktop/api/objidl/nf-objidl-ipersist-getclassid HRESULT GetClassID( CLSID *pClassID );
new Guid GetClassID();
/// <summary>Instructs a Shell folder object to initialize itself based on the information passed.</summary>
/// <param name="pidl">
/// <para>Type: <c>LPCITEMIDLIST</c></para>
/// <para>The address of the ITEMIDLIST (item identifier list) structure that specifies the absolute location of the folder.</para>
/// </param>
/// <remarks>
/// <para>
/// All objects that implement the IShellFolder interface for use in the Shell's namespace must implement this method. When a
/// folder's location in the namespace is not a relevant consideration, this method can simply return S_OK. When the location is
/// relevant to the folder, you should store the fully qualified IDLIST passed in for later reference.
/// </para>
/// <para>
/// For example, if the folder implementation needs to construct a fully qualified pointer to an item identifier list (PIDL) to
/// elements that it contains, the PIDL passed to this method should be used to construct the fully qualified PIDLs.
/// </para>
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-ipersistfolder-initialize HRESULT
// Initialize( PCIDLIST_ABSOLUTE pidl );
new void Initialize([In] PIDL pidl);
/// <summary>Gets the ITEMIDLIST for the folder object.</summary>
/// <param name="ppidl">
/// <para>Type: <c>LPITEMIDLIST*</c></para>
/// <para>
/// The address of an ITEMIDLIST pointer. This PIDL represents the absolute location of the folder and must be relative to the
/// desktop. This is typically a copy of the PIDL passed to Initialize.
/// </para>
/// </param>
/// <returns>
/// <para>Type: <c>HRESULT</c></para>
/// <para>If this method succeeds, it returns <c>S_OK</c>. Otherwise, it returns an <c>HRESULT</c> error code.</para>
/// </returns>
/// <remarks>If the folder object has not been initialized, this method returns S_FALSE and ppidl is set to <c>NULL</c>.</remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-ipersistfolder2-getcurfolder HRESULT
// GetCurFolder( PIDLIST_ABSOLUTE *ppidl );
[PreserveSig]
new HRESULT GetCurFolder(ref PIDL ppidl);
/// <summary>
/// Initializes a folder and specifies its location in the namespace. If the folder is a shortcut, this method also specifies
/// the location of the target folder.
/// </summary>
/// <param name="pbc">
/// <para>Type: <c>IBindCtx*</c></para>
/// <para>A pointer to an IBindCtx object that provides the bind context. This parameter can be <c>NULL</c>.</para>
/// </param>
/// <param name="pidlRoot">
/// <para>Type: <c>LPCITEMIDLIST</c></para>
/// <para>
/// A pointer to a fully qualified PIDL that specifies the absolute location of a folder or folder shortcut. The calling
/// application is responsible for allocating and freeing this PIDL.
/// </para>
/// </param>
/// <param name="ppfti">
/// <para>Type: <c>const PERSIST_FOLDER_TARGET_INFO*</c></para>
/// <para>A pointer to a PERSIST_FOLDER_TARGET_INFO structure that specifies the location of the target folder and its attributes.</para>
/// <para>If ppfti points to a valid structure, pidlRoot represents a folder shortcut.</para>
/// <para>
/// If ppfti is set to <c>NULL</c>, pidlRoot represents a normal folder. In that case, <c>InitializeEx</c> should behave as if
/// Initialize had been called.
/// </para>
/// </param>
/// <returns>
/// <para>Type: <c>HRESULT</c></para>
/// <para>If this method succeeds, it returns <c>S_OK</c>. Otherwise, it returns an <c>HRESULT</c> error code.</para>
/// </returns>
/// <remarks>
/// This function is an extended version of IPersistFolder::Initialize. It allows the Shell to initialize folder shortcuts as
/// well as normal folders.
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-ipersistfolder3-initializeex HRESULT
// InitializeEx( IBindCtx *pbc, PCIDLIST_ABSOLUTE pidlRoot, const PERSIST_FOLDER_TARGET_INFO *ppfti );
void InitializeEx([In] IBindCtx pbc, [In] PIDL pidlRoot, in PERSIST_FOLDER_TARGET_INFO ppfti);
/// <summary>Provides the location and attributes of a folder shortcut's target folder.</summary>
/// <returns>
/// <para>Type: <c>PERSIST_FOLDER_TARGET_INFO*</c></para>
/// <para>A pointer to a PERSIST_FOLDER_TARGET_INFO structure used to return the target folder's location and attributes.</para>
/// </returns>
/// <remarks>
/// The PERSIST_FOLDER_TARGET_INFO structure might not be initialized by the caller. <c>GetFolderTargetInfo</c> must assign
/// values to all members of the structure before returning it to the caller.
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-ipersistfolder3-getfoldertargetinfo HRESULT
// GetFolderTargetInfo( PERSIST_FOLDER_TARGET_INFO *ppfti );
PERSIST_FOLDER_TARGET_INFO GetFolderTargetInfo();
}
/// <summary>
/// Specifies a folder shortcut's target folder and its attributes. This structure is used by IPersistFolder3::GetFolderTargetInfo
/// and IPersistFolder3::InitializeEx.
/// </summary>
/// <remarks>
/// Any or all of the <c>pidlTargetFolder</c>, <c>szTargetParsingName</c>, and <c>csidl</c> members can be used to specify the
/// target folder's location.
/// </remarks>
// https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/ns-shobjidl_core-persist_folder_target_info typedef struct
// _PERSIST_FOLDER_TARGET_INFO { PIDLIST_ABSOLUTE pidlTargetFolder; WCHAR szTargetParsingName[260]; WCHAR szNetworkProvider[260];
// DWORD dwAttributes; int csidl; } PERSIST_FOLDER_TARGET_INFO;
[PInvokeData("shobjidl_core.h", MSDNShortId = "NS:shobjidl_core._PERSIST_FOLDER_TARGET_INFO")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct PERSIST_FOLDER_TARGET_INFO
{
/// <summary>
/// <para>Type: <c>PIDLIST_ABSOLUTE</c></para>
/// <para>A fully qualified PIDL of the target folder. Set <c>pidlTargetFolder</c> to <c>NULL</c> if not specified.</para>
/// </summary>
public IntPtr pidlTargetFolder;
/// <summary>
/// <para>Type: <c>WCHAR[MAX_PATH]</c></para>
/// <para>
/// A null-terminated Unicode string with the target folder's parsing name. Set <c>szTargetParsingName</c> to an empty string if
/// not specified.
/// </para>
/// </summary>
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
public string szTargetParsingName;
/// <summary>
/// <para>Type: <c>WCHAR[MAX_PATH]</c></para>
/// <para>
/// A null-terminated Unicode string that specifies the type of network provider that will be used when binding to the target
/// folder. The format is the same as that used by the WNet API. Set <c>szNetworkProvider</c> to an empty string if not specified.
/// </para>
/// </summary>
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
public string szNetworkProvider;
/// <summary>
/// <para>Type: <c>DWORD</c></para>
/// <para>
/// A <c>DWORD</c> value that contains FILE_ATTRIBUTE_* flags as defined in Winnt.h. Set <c>dwAttributes</c> to -1 if not specified.
/// </para>
/// </summary>
public FileFlagsAndAttributes dwAttributes;
/// <summary>
/// <para>Type: <c>int</c></para>
/// <para>
/// The target folder's CSIDL value, if it has one. Set <c>csidl</c> to -1 if the target folder does not have a CSIDL. In
/// addition to the CSIDL value, you can also set the following two flags.
/// </para>
/// <para>CSIDL_FLAG_PFTI_TRACKTARGET</para>
/// <para>Indicates that the target folder should change if the user changes the target folder's underlying CSIDL value.</para>
/// <para>CSIDL_FLAG_CREATE</para>
/// <para>Indicates that the target folder should be created if it does not already exist.</para>
/// </summary>
public CSIDL csidl;
}
}
}