Exemple #1
0
 /// <summary>
 /// Initialises a new instance of the <see cref="ShellContextMenu"/>
 /// class.
 /// </summary>
 ///
 /// <param name="item">
 /// The item to which the context menu should refer.
 /// </param>
 public ContextShellMenu(ShellObject item)
 {
     Initialize(new ShellObject[] { item });
 }
 public void NewItem(ShellObject destinationFolder, FileAttributes fileAttributes, string name, string templateName, FileOperationProgressSink pfopsItem) => NewItem(destinationFolder.NativeShellItem, fileAttributes, name, templateName, pfopsItem);
Exemple #3
0
        public bool GetNewContextMenu(ShellObject item, out object iContextMenuPtr, out IContextMenu iContextMenu)
        {
            Guid CLSID_NewMenu = new Guid("{D969A300-E7FF-11d0-A93B-00A0C90F2719}");
            Guid iicm          = typeof(IContextMenu).GUID;
            Guid iise          = typeof(IShellExtInit).GUID;

            if (WindowsAPI.CoCreateInstance(
                    ref CLSID_NewMenu,
                    IntPtr.Zero,
                    0x1,
                    ref iicm,
                    out iContextMenuPtr) == (int)HResult.Ok)
            {
                iContextMenu = iContextMenuPtr as IContextMenu;

                IntPtr iShellExtInitPtr;
                if (Marshal.QueryInterface(
                        Marshal.GetIUnknownForObject(iContextMenuPtr),
                        ref iise,
                        out iShellExtInitPtr) == (int)HResult.Ok)
                {
                    IShellExtInit iShellExtInit = Marshal.GetTypedObjectForIUnknown(
                        iShellExtInitPtr, typeof(IShellExtInit)) as IShellExtInit;

                    try
                    {
                        iShellExtInit.Initialize(item.PIDL, IntPtr.Zero, 0);

                        Marshal.ReleaseComObject(iShellExtInit);
                        Marshal.Release(iShellExtInitPtr);

                        return(true);
                    }
                    finally
                    {
                    }
                }
                else
                {
                    if (iContextMenu != null)
                    {
                        Marshal.ReleaseComObject(iContextMenu);
                        iContextMenu = null;
                    }

                    if (iContextMenuPtr != null)
                    {
                        Marshal.ReleaseComObject(iContextMenuPtr);
                        iContextMenuPtr = null;
                    }

                    return(false);
                }
            }
            else
            {
                iContextMenuPtr = IntPtr.Zero;
                iContextMenu    = null;
                return(false);
            }
        }
 public void DeleteItem(ShellObject shellObject, FileOperationProgressSink pfopsItem) => DeleteItem(shellObject.NativeShellItem, pfopsItem);
 public void CopyItem(ShellObject shellObject, ShellObject destinationFolder, string copyName, FileOperationProgressSink pfopsItem) => CopyItem(shellObject.NativeShellItem, destinationFolder.NativeShellItem, copyName, pfopsItem);
 public void MoveItem(ShellObject shellObject, ShellObject destinationShellObject, string newName, FileOperationProgressSink pfopsItem) => MoveItem(shellObject.NativeShellItem, destinationShellObject.NativeShellItem, newName, pfopsItem);
 public void RenameItem(ShellObject shellObject, string newName, FileOperationProgressSink pfopsItem) => RenameItem(shellObject.NativeShellItem, newName, pfopsItem);
 public void ApplyPropertiesToItem(ShellObject shellObject) => ApplyPropertiesToItem(shellObject.NativeShellItem);