Skip to content

Commit

Permalink
tried implementing ipersistidlist to no avail.
Browse files Browse the repository at this point in the history
  • Loading branch information
dwmkerr committed Jan 29, 2014
1 parent 2c3b96b commit c7d0621
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 4 deletions.
2 changes: 1 addition & 1 deletion SharpShell/SharpShell/Interop/CMINVOKECOMMANDINFO.cs
Expand Up @@ -53,5 +53,5 @@ public struct CMINVOKECOMMANDINFO
/// An icon to use for any application activated by the command. If the fMask member does not specify CMIC_MASK_ICON, this member is ignored.
/// </summary>
public IntPtr hIcon;
}
}
}
32 changes: 32 additions & 0 deletions SharpShell/SharpShell/Interop/IPersistIDList.cs
@@ -0,0 +1,32 @@
using System;
using System.Runtime.InteropServices;

namespace SharpShell.Interop
{
/// <summary>
/// Exposes methods that are used to persist item identifier lists.
/// </summary>
[ComImport, Guid("1079acfc-29bd-11d3-8e0d-00c04f6837d5"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IPersistIDList : IPersist
{
#region Overriden IPersist Methods

int GetClassID(out Guid pClassID);

#endregion

/// <summary>
/// Sets a persisted item identifier list.
/// </summary>
/// <param name="pidl">A pointer to the item identifier list to set.</param>
/// <returns>If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</returns>
int SetIDList([In] IntPtr pidl);

/// <summary>
/// Gets an item identifier list.
/// </summary>
/// <param name="pidl">The address of a pointer to the item identifier list to get.</param>
/// <returns>If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</returns>
int GetIDList([Out] out IntPtr pidl);
}
}
Binary file modified SharpShell/SharpShell/NativeBridge/SharpShellNativeBridge64.dll
Binary file not shown.
Expand Up @@ -32,6 +32,7 @@ namespace SharpShell.SharpNamespaceExtension
public abstract class SharpNamespaceExtension :
SharpShellServer,
IPersistFolder2,
IPersistIDList,
IShellFolder2,
IShellNamespaceFolder

Expand Down Expand Up @@ -65,6 +66,7 @@ int IPersist.GetClassID(out Guid pClassID)
}
int IPersistFolder.GetClassID(out Guid pClassId) {return ((IPersist)this).GetClassID(out pClassId); }
int IPersistFolder2.GetClassID(out Guid pClassId) { return ((IPersist)this).GetClassID(out pClassId); }
int IPersistIDList.GetClassID(out Guid pClassId) { return ((IPersist)this).GetClassID(out pClassId); }

/// <summary>
/// Instructs a Shell folder object to initialize itself based on the information passed.
Expand Down Expand Up @@ -109,6 +111,18 @@ int IPersistFolder2.GetCurFolder(out IntPtr ppidl)
ppidl = PidlManager.IdListToPidl(extensionAbsolutePidl);
return WinError.S_OK;
}


int IPersistIDList.SetIDList(IntPtr pidl)
{
return ((IPersistFolder2)this).Initialize(pidl);
}

int IPersistIDList.GetIDList([Out] out IntPtr pidl)
{
return ((IPersistFolder2)this).GetCurFolder(out pidl);
}


#endregion

Expand Down
18 changes: 15 additions & 3 deletions SharpShell/SharpShell/SharpNamespaceExtension/ShellFolderProxy.cs
@@ -1,12 +1,13 @@
using System;
using System.Runtime.InteropServices;
using SharpShell.Interop;
using SharpShell.Pidl;

namespace SharpShell.SharpNamespaceExtension
{
// todo important we can merge this class an shellfolderimpl

internal class ShellFolderProxy : IShellFolder2, IPersistFolder2
internal class ShellFolderProxy : IShellFolder2, IPersistFolder2, IPersistIDList
{
public ShellFolderProxy(IShellNamespaceFolder folder, Guid serverGuid, IdList idList)
{
Expand Down Expand Up @@ -303,7 +304,7 @@ int IShellFolder2.MapColumnToSCID(uint iColumn, out PROPERTYKEY pscid)

#endregion

#region Implementation IPersist, IPersistFolder, IPersistFolder2
#region Implementation IPersist, IPersistFolder, IPersistFolder2, IPersistIDList

/// <summary>
/// Gets the class identifier.
Expand All @@ -318,6 +319,7 @@ int IPersist.GetClassID(out Guid pClassID)
}
int IPersistFolder.GetClassID(out Guid pClassID) { return ((IPersist)this).GetClassID(out pClassID); }
int IPersistFolder2.GetClassID(out Guid pClassID) { return ((IPersist)this).GetClassID(out pClassID); }
int IPersistIDList.GetClassID(out Guid pClassID) {return ((IPersist)this).GetClassID(out pClassID); }

int IPersistFolder.Initialize(IntPtr pidl)
{
Expand All @@ -337,13 +339,23 @@ int IPersistFolder.Initialize(IntPtr pidl)
/// <remarks>
/// If the folder object has not been initialized, this method returns S_FALSE and ppidl is set to NULL.
/// </remarks>
public int GetCurFolder(out IntPtr ppidl)
int IPersistFolder2.GetCurFolder(out IntPtr ppidl)
{
// Return the pidl.
ppidl = PidlManager.IdListToPidl(folderIdList);
return WinError.S_OK;
}

int IPersistIDList.SetIDList(IntPtr pidl)
{
return ((IPersistFolder2) this).Initialize(pidl);
}

int IPersistIDList.GetIDList([Out] out IntPtr pidl)
{
return ((IPersistFolder2) this).GetCurFolder(out pidl);
}

#endregion

private readonly IShellNamespaceFolder folder;
Expand Down
1 change: 1 addition & 0 deletions SharpShell/SharpShell/SharpShell.csproj
Expand Up @@ -91,6 +91,7 @@
<Compile Include="Interop\IDefaultExtractIconInit.cs" />
<Compile Include="Interop\IExtractIconA.cs" />
<Compile Include="Interop\IExtractIconW.cs" />
<Compile Include="Interop\IPersistIDList.cs" />
<Compile Include="Interop\LVCFMT.cs" />
<Compile Include="Interop\PROPERTYKEY.cs" />
<Compile Include="Interop\CSFV.cs" />
Expand Down

0 comments on commit c7d0621

Please sign in to comment.