コード例 #1
0
 private static IShellItem2 CreateItemFromJumpPath(JumpPath jumpPath)
 {
     Debug.Assert(jumpPath != null);
     try
     {
         return(GetShellItemForPath(Path.GetFullPath(jumpPath.Path)));
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
     return(null);
 }
コード例 #2
0
        private static JumpItem GetJumpItemForShellObject(object shellObject)
        {
            var shellItem = shellObject as IShellItem2;
            var shellLink = shellObject as IShellLinkW;

            if (shellItem != null)
            {
                var path = new JumpPath {
                    Path = shellItem.GetDisplayName(SIGDN.DESKTOPABSOLUTEPARSING),
                };
                return(path);
            }
            if (shellLink != null)
            {
                var pathBuilder = new StringBuilder((int)Win32Value.MAX_PATH);
                shellLink.GetPath(pathBuilder, pathBuilder.Capacity, null, SLGP.RAWPATH);
                var argsBuilder = new StringBuilder((int)Win32Value.INFOTIPSIZE);
                shellLink.GetArguments(argsBuilder, argsBuilder.Capacity);
                var descBuilder = new StringBuilder((int)Win32Value.INFOTIPSIZE);
                shellLink.GetDescription(descBuilder, descBuilder.Capacity);
                var iconBuilder = new StringBuilder((int)Win32Value.MAX_PATH);
                int iconIndex;
                shellLink.GetIconLocation(iconBuilder, iconBuilder.Capacity, out iconIndex);
                var dirBuilder = new StringBuilder((int)Win32Value.MAX_PATH);
                shellLink.GetWorkingDirectory(dirBuilder, dirBuilder.Capacity);
                var task = new JumpTask
                {
                    ApplicationPath   = pathBuilder.ToString(),
                    Arguments         = argsBuilder.ToString(),
                    Description       = descBuilder.ToString(),
                    IconResourceIndex = iconIndex,
                    IconResourcePath  = iconBuilder.ToString(),
                    WorkingDirectory  = dirBuilder.ToString(),
                };
                using (var pv = new PROPVARIANT())
                {
                    var propStore = (IPropertyStore)shellLink;
                    var pkeyTitle = PKEY.Title;
                    propStore.GetValue(ref pkeyTitle, pv);

                    task.Title = pv.GetValue() ?? "";
                }
                return(task);
            }

            Debug.Assert(false);
            return(null);
        }
コード例 #3
0
 public static void AddToRecentCategory(JumpPath jumpPath)
 {
     Verify.IsNotNull(jumpPath, "jumpPath");
     AddToRecentCategory(jumpPath.Path);
 }