/// <summary> /// Retrieves an IShellFolder object for a subfolder. /// Return value: error code, if any /// </summary> /// <param name="pidl">Address of an ITEMIDLIST structure (PIDL) that identifies the subfolder.</param> /// <param name="pbc">Optional address of an IBindCtx interface on a bind context object to be used during this operation.</param> /// <param name="riid">Identifier of the interface to return. </param> /// <param name="ppv">Address that receives the interface pointer.</param> /// <returns>If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</returns> int IShellFolder.BindToObject(IntPtr pidl, IntPtr pbc, ref Guid riid, out IntPtr ppv) { // Have we been asked to bind to a folder? if (riid == typeof(IShellFolder).GUID || riid == typeof(IShellFolder2).GUID) { // Get the child item. var idList = PidlManager.PidlToIdlist(pidl); var childItem = GetChildItem(idList); // If the item is a folder, we can create a proxy for it and return the proxy. var subFolder = childItem as IShellNamespaceFolder; if (subFolder != null) { var folderProxy = new ShellFolderImpl(namespaceExtension, subFolder); ppv = Marshal.GetComInterfaceForObject(folderProxy, typeof(IShellFolder2)); return(WinError.S_OK); } } // Note: We are also asked to bind to IPropertyStore IPropertyStoreFactory and IPropertyStoreCache. // If we cannot return the required interface, we must return no interface. ppv = IntPtr.Zero; return(WinError.E_NOINTERFACE); }
/// <summary> /// Initializes a new instance of the <see cref="SharpNamespaceExtension"/> class. /// </summary> protected SharpNamespaceExtension() { Log("Instatiated Namespace Extension"); // Create the shell folder implementation. shellFolderImpl = new ShellFolderImpl(this, this); }
/// <summary> /// Retrieves an IShellFolder object for a subfolder. // Return value: error code, if any /// </summary> /// <param name="pidl">Address of an ITEMIDLIST structure (PIDL) that identifies the subfolder.</param> /// <param name="pbc">Optional address of an IBindCtx interface on a bind context object to be used during this operation.</param> /// <param name="riid">Identifier of the interface to return. </param> /// <param name="ppv">Address that receives the interface pointer.</param> /// <returns>If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</returns> int IShellFolder.BindToObject(IntPtr pidl, IntPtr pbc, ref Guid riid, out IntPtr ppv) { // Have we been asked to bind to a folder? if (riid == typeof(IShellFolder).GUID || riid == typeof(IShellFolder2).GUID) { // Get the child item. var idList = PidlManager.PidlToIdlist(pidl); var childItem = GetChildItem(idList); // If the item is a folder, we can create a proxy for it and return the proxy. var subFolder = childItem as IShellNamespaceFolder; if (subFolder != null) { var folderProxy = new ShellFolderImpl(namespaceExtension, subFolder); ppv = Marshal.GetComInterfaceForObject(folderProxy, typeof(IShellFolder2)); return WinError.S_OK; } } // Note: We are also asked to bind to IPropertyStore IPropertyStoreFactory and IPropertyStoreCache. // If we cannot return the required interface, we must return no interface. ppv = IntPtr.Zero; return WinError.E_NOINTERFACE; }