private static void AddCategory(Standard.ICustomDestinationList cdl, string category, List <_ShellObjectPair> jumpItems, List <JumpItem> successList, List <_RejectedJumpItemPair> rejectionList, bool isHeterogenous) { Standard.HRESULT hresult; Standard.IObjectCollection poa = (Standard.IObjectCollection)Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid("2d3468c1-36a7-43b6-ac24-d3f02fd9607a"))); foreach (_ShellObjectPair pair in jumpItems) { poa.AddObject(pair.ShellObject); } if (string.IsNullOrEmpty(category)) { hresult = cdl.AddUserTasks(poa); } else { hresult = cdl.AppendCategory(category, poa); } if (hresult.Succeeded) { int count = jumpItems.Count; while (--count >= 0) { successList.Add(jumpItems[count].JumpItem); } } else if (isHeterogenous && (hresult == Standard.HRESULT.DESTS_E_NO_MATCHING_ASSOC_HANDLER)) { Standard.Utility.SafeRelease <Standard.IObjectCollection>(ref poa); List <_ShellObjectPair> list = new List <_ShellObjectPair>(); foreach (_ShellObjectPair pair2 in jumpItems) { if (pair2.JumpItem is JumpPath) { _RejectedJumpItemPair item = new _RejectedJumpItemPair { JumpItem = pair2.JumpItem, Reason = JumpItemRejectionReason.NoRegisteredHandler }; rejectionList.Add(item); } else { list.Add(pair2); } } if (list.Count > 0) { AddCategory(cdl, category, list, successList, rejectionList, false); } } else { foreach (_ShellObjectPair pair4 in jumpItems) { _RejectedJumpItemPair pair5 = new _RejectedJumpItemPair { JumpItem = pair4.JumpItem, Reason = JumpItemRejectionReason.InvalidItem }; rejectionList.Add(pair5); } } }
private static void AddCategory(Standard.ICustomDestinationList cdl, string category, List <_ShellObjectPair> jumpItems, List <JumpItem> successList, List <_RejectedJumpItemPair> rejectionList) { AddCategory(cdl, category, jumpItems, successList, rejectionList, true); }
private void _BuildShellLists(out List <JumpItem> successList, out List <_RejectedJumpItemPair> rejectedList, out List <_ShellObjectPair> removedList) { List <List <_ShellObjectPair> > list = null; removedList = null; Standard.ICustomDestinationList cdl = Standard.CLSID.CoCreateInstance <Standard.ICustomDestinationList>("77f10cf0-3db5-4966-b520-b7c54fd35ed6"); try { uint num; string str = _RuntimeId; if (!string.IsNullOrEmpty(str)) { cdl.SetAppID(str); } Guid riid = new Guid("92CA9DCD-5622-4bba-A805-5E9F541BD8C9"); Standard.IObjectArray shellObjects = (Standard.IObjectArray)cdl.BeginList(out num, ref riid); removedList = GenerateJumpItems(shellObjects); successList = new List <JumpItem>(this.JumpItems.Count); rejectedList = new List <_RejectedJumpItemPair>(this.JumpItems.Count); list = new List <List <_ShellObjectPair> > { new List <_ShellObjectPair>() }; foreach (JumpItem item in this.JumpItems) { if (item == null) { _RejectedJumpItemPair pair = new _RejectedJumpItemPair { JumpItem = item, Reason = JumpItemRejectionReason.InvalidItem }; rejectedList.Add(pair); } else { object shellObject = null; try { shellObject = GetShellObjectForJumpItem(item); if (shellObject == null) { _RejectedJumpItemPair pair2 = new _RejectedJumpItemPair { Reason = JumpItemRejectionReason.InvalidItem, JumpItem = item }; rejectedList.Add(pair2); } else if (ListContainsShellObject(removedList, shellObject)) { _RejectedJumpItemPair pair3 = new _RejectedJumpItemPair { Reason = JumpItemRejectionReason.RemovedByUser, JumpItem = item }; rejectedList.Add(pair3); } else { _ShellObjectPair pair4 = new _ShellObjectPair { JumpItem = item, ShellObject = shellObject }; if (string.IsNullOrEmpty(item.CustomCategory)) { list[0].Add(pair4); } else { bool flag = false; foreach (List <_ShellObjectPair> list3 in list) { if ((list3.Count > 0) && (list3[0].JumpItem.CustomCategory == item.CustomCategory)) { list3.Add(pair4); flag = true; break; } } if (!flag) { list.Add(new List <_ShellObjectPair> { pair4 }); } } shellObject = null; } } finally { Standard.Utility.SafeRelease <object>(ref shellObject); } } } list.Reverse(); if (this.ShowFrequentCategory) { cdl.AppendKnownCategory(Standard.KDC.FREQUENT); } if (this.ShowRecentCategory) { cdl.AppendKnownCategory(Standard.KDC.RECENT); } foreach (List <_ShellObjectPair> list5 in list) { if (list5.Count > 0) { string customCategory = list5[0].JumpItem.CustomCategory; AddCategory(cdl, customCategory, list5, successList, rejectedList); } } cdl.CommitList(); successList.Reverse(); } finally { Standard.Utility.SafeRelease <Standard.ICustomDestinationList>(ref cdl); if (list != null) { foreach (List <_ShellObjectPair> list7 in list) { _ShellObjectPair.ReleaseShellObjects(list7); } } _ShellObjectPair.ReleaseShellObjects(removedList); } }