internal ExtendedListViewCommon(ShellBrowserEx shellBrowser, IntPtr hwndShellView, IntPtr hwndListView, IntPtr hwndSubDirTipMessageReflect) { ShellBrowser = shellBrowser; this.hwndSubDirTipMessageReflect = hwndSubDirTipMessageReflect; ListViewController = new NativeWindowController(hwndListView); ListViewController.MessageCaptured += ListViewController_MessageCaptured; ShellViewController = new NativeWindowController(hwndShellView); ShellViewController.MessageCaptured += ShellViewController_MessageCaptured; TRACKMOUSEEVENT structure = new TRACKMOUSEEVENT(); structure.cbSize = Marshal.SizeOf(structure); structure.dwFlags = 2; structure.hwndTrack = ListViewController.Handle; PInvoke.TrackMouseEvent(ref structure); timer_HoverSubDirTipMenu = new Timer(); timer_HoverSubDirTipMenu.Interval = SystemInformation.MouseHoverTime * 6 / 5; timer_HoverSubDirTipMenu.Tick += timer_HoverSubDirTipMenu_Tick; hwndExplorer = PInvoke.GetAncestor(hwndShellView, 3 /* GA_ROOTOWNER */); // If we're late to the party, we'll have to get the IDropTarget the // old-fashioned way. Careful! Calling RegisterDragDrop will go // through the hook! IntPtr ptr = PInvoke.GetProp(hwndListView, "OleDropTargetInterface"); dropTargetPassthrough = TryMakeDTPassthrough(ptr); if(dropTargetPassthrough != null) { PInvoke.RevokeDragDrop(hwndListView); PInvoke.RegisterDragDrop(hwndListView, dropTargetPassthrough); } }
public MenuItemArguments(UserApp app, ShellBrowserEx shellBrowser, MenuGenre genre) { App = app; Path = app.Path; ShellBrowser = shellBrowser; Genre = genre; }
internal ExtendedListViewCommon(ShellBrowserEx shellBrowser, IntPtr hwndShellView, IntPtr hwndListView, IntPtr hwndSubDirTipMessageReflect) { ShellBrowser = shellBrowser; this.hwndSubDirTipMessageReflect = hwndSubDirTipMessageReflect; ListViewController = new NativeWindowController(hwndListView); ListViewController.MessageCaptured += ListViewController_MessageCaptured; ShellViewController = new NativeWindowController(hwndShellView); ShellViewController.MessageCaptured += ShellViewController_MessageCaptured; TRACKMOUSEEVENT structure = new TRACKMOUSEEVENT(); structure.cbSize = Marshal.SizeOf(structure); structure.dwFlags = 2; structure.hwndTrack = ListViewController.Handle; PInvoke.TrackMouseEvent(ref structure); timer_HoverSubDirTipMenu = new Timer(); timer_HoverSubDirTipMenu.Interval = SystemInformation.MouseHoverTime * 6 / 5; timer_HoverSubDirTipMenu.Tick += timer_HoverSubDirTipMenu_Tick; hwndExplorer = PInvoke.GetAncestor(hwndShellView, 3 /* GA_ROOTOWNER */); // If we're late to the party, we'll have to get the IDropTarget the // old-fashioned way. Careful! Calling RegisterDragDrop will go // through the hook! IntPtr ptr = PInvoke.GetProp(hwndListView, "OleDropTargetInterface"); dropTargetPassthrough = TryMakeDTPassthrough(ptr); if (dropTargetPassthrough != null) { PInvoke.RevokeDragDrop(hwndListView); PInvoke.RegisterDragDrop(hwndListView, dropTargetPassthrough); } }
public static List<ToolStripItem> CreateAppLauncherItems(IntPtr hwndParent, ShellBrowserEx shellBrowser, bool fReorderEnabled, ItemRightClickedEventHandler rightClickHandler, EventHandler dirDoubleClickEvent, bool fFromTaskBar) { // todo: refresh? EventPack ep = new EventPack(hwndParent, rightClickHandler, dirDoubleClickEvent, fFromTaskBar); return AppsManager.BuildNestedStructure( userApp => CreateMenuItem_AppLauncher(userApp, ep, shellBrowser), (folderName, children) => CreateMenuItem_AppLauncher_Virtual( folderName, children, fReorderEnabled, ep)).ToList(); }
public static List <ToolStripItem> CreateAppLauncherItems(IntPtr hwndParent, ShellBrowserEx shellBrowser, bool fReorderEnabled, ItemRightClickedEventHandler rightClickHandler, EventHandler dirDoubleClickEvent, bool fFromTaskBar) { // todo: refresh? EventPack ep = new EventPack(hwndParent, rightClickHandler, dirDoubleClickEvent, fFromTaskBar); return(AppsManager.BuildNestedStructure( userApp => CreateMenuItem_AppLauncher(userApp, ep, shellBrowser), (folderName, children) => CreateMenuItem_AppLauncher_Virtual( folderName, children, fReorderEnabled, ep)).ToList()); }
internal ListViewMonitor(ShellBrowserEx shellBrowser, IntPtr hwndExplorer, IntPtr hwndSubDirTipMessageReflect) { ShellBrowser = shellBrowser; this.hwndExplorer = hwndExplorer; this.hwndSubDirTipMessageReflect = hwndSubDirTipMessageReflect; hwndShellContainer = QTUtility.IsXP ? hwndExplorer : WindowUtils.FindChildWindow(hwndExplorer, hwnd => PInvoke.GetClassName(hwnd) == "ShellTabWindowClass"); if(hwndShellContainer != IntPtr.Zero) { ContainerController = new NativeWindowController(hwndShellContainer); ContainerController.MessageCaptured += ContainerController_MessageCaptured; } }
internal ListViewMonitor(ShellBrowserEx shellBrowser, IntPtr hwndExplorer, IntPtr hwndSubDirTipMessageReflect) { ShellBrowser = shellBrowser; this.hwndExplorer = hwndExplorer; this.hwndSubDirTipMessageReflect = hwndSubDirTipMessageReflect; hwndShellContainer = QTUtility.IsXP ? hwndExplorer : WindowUtils.FindChildWindow(hwndExplorer, hwnd => PInvoke.GetClassName(hwnd) == "ShellTabWindowClass"); if (hwndShellContainer != IntPtr.Zero) { ContainerController = new NativeWindowController(hwndShellContainer); ContainerController.MessageCaptured += ContainerController_MessageCaptured; } }
internal ListViewMonitor(ShellBrowserEx shellBrowser, IntPtr hwndExplorer, IntPtr hwndSubDirTipMessageReflect) { ShellBrowser = shellBrowser; this.hwndExplorer = hwndExplorer; this.hwndSubDirTipMessageReflect = hwndSubDirTipMessageReflect; if(!QTUtility.IsXP) { hwndEnumResult = IntPtr.Zero; PInvoke.EnumChildWindows(hwndExplorer, CallbackEnumChildProc_Container, IntPtr.Zero); hwndShellContainer = hwndEnumResult; } else { hwndShellContainer = hwndExplorer; } if(hwndShellContainer != IntPtr.Zero) { ContainerController = new NativeWindowController(hwndShellContainer); ContainerController.MessageCaptured += ContainerController_MessageCaptured; } }
internal ListViewMonitor(ShellBrowserEx shellBrowser, IntPtr hwndExplorer, IntPtr hwndSubDirTipMessageReflect) { ShellBrowser = shellBrowser; this.hwndExplorer = hwndExplorer; this.hwndSubDirTipMessageReflect = hwndSubDirTipMessageReflect; if (!QTUtility.IsXP) { hwndEnumResult = IntPtr.Zero; PInvoke.EnumChildWindows(hwndExplorer, CallbackEnumChildProc_Container, IntPtr.Zero); hwndShellContainer = hwndEnumResult; } else { hwndShellContainer = hwndExplorer; } if (hwndShellContainer != IntPtr.Zero) { ContainerController = new NativeWindowController(hwndShellContainer); ContainerController.MessageCaptured += ContainerController_MessageCaptured; } }
internal ExtendedListViewCommon(ShellBrowserEx shellBrowser, IntPtr hwndShellView, IntPtr hwndListView, IntPtr hwndSubDirTipMessageReflect) { ShellBrowser = shellBrowser; this.hwndSubDirTipMessageReflect = hwndSubDirTipMessageReflect; ListViewController = new NativeWindowController(hwndListView); ListViewController.MessageCaptured += ListViewController_MessageCaptured; ShellViewController = new NativeWindowController(hwndShellView); ShellViewController.MessageCaptured += ShellViewController_MessageCaptured; TRACKMOUSEEVENT structure = new TRACKMOUSEEVENT(); structure.cbSize = Marshal.SizeOf(structure); structure.dwFlags = 2; structure.hwndTrack = ListViewController.Handle; PInvoke.TrackMouseEvent(ref structure); timer_HoverSubDirTipMenu = new Timer(); timer_HoverSubDirTipMenu.Interval = SystemInformation.MouseHoverTime * 6 / 5; timer_HoverSubDirTipMenu.Tick += timer_HoverSubDirTipMenu_Tick; hwndExplorer = PInvoke.GetAncestor(hwndShellView, 3 /* GA_ROOTOWNER */); HookDropTarget(); }
public override void CloseDW(uint dwReserved) { if(iContextMenu2 != null) { Marshal.ReleaseComObject(iContextMenu2); iContextMenu2 = null; } if(ShellBrowser != null) { ShellBrowser.Dispose(); ShellBrowser = null; } lock(this) { if(listView != null) { listView.RemoteDispose(); listView = null; } } DisposeInvoker method = disposable => disposable.Dispose(); if(hashForm != null) { hashForm.Invoke(method, new object[] { hashForm }); hashForm = null; } if(hHook_MsgDesktop != IntPtr.Zero) { PInvoke.UnhookWindowsHookEx(hHook_MsgDesktop); hHook_MsgDesktop = IntPtr.Zero; } if(hHook_MsgShell_TrayWnd != IntPtr.Zero) { PInvoke.UnhookWindowsHookEx(hHook_MsgShell_TrayWnd); hHook_MsgShell_TrayWnd = IntPtr.Zero; } if(hHook_KeyDesktop != IntPtr.Zero) { PInvoke.UnhookWindowsHookEx(hHook_KeyDesktop); hHook_KeyDesktop = IntPtr.Zero; } base.CloseDW(dwReserved); }
private IntPtr CallbackGetMsgProc_Desktop(int nCode, IntPtr wParam, IntPtr lParam) { if(nCode >= 0) { MSG msg = (MSG)Marshal.PtrToStructure(lParam, typeof(MSG)); if(msg.hwnd == hwndListView && msg.message == WM.APP + 100) { IntPtr hwnd = PInvoke.FindWindowEx(IntPtr.Zero, IntPtr.Zero, "Progman", null); IntPtr pUnk = PInvoke.SendMessage(hwnd, WM.USER + 7, IntPtr.Zero, IntPtr.Zero); if(pUnk == IntPtr.Zero) { timerISV = new Timer(); timerISV.Tag = msg.hwnd; timerISV.Tick += (sender, args) => { PInvoke.PostMessage((IntPtr)timerISV.Tag, WM.APP + 100, IntPtr.Zero, IntPtr.Zero); timerISV.Enabled = false; }; timerISV.Interval = 2000; timerISV.Start(); } else { ShellBrowser = new ShellBrowserEx((IShellBrowser)Marshal.GetObjectForIUnknown(pUnk), true); listView = new ExtendedSysListView32(ShellBrowser, PInvoke.GetParent(hwndListView), hwndListView, ThisHandle); listView.MouseActivate += ListView_MouseActivate; listView.SelectionActivated += ListView_SelectionActivated; listView.MiddleClick += ListView_MiddleClick; listView.DoubleClick += ListView_DoubleClick; listView.ListViewDestroyed += ListView_Destroyed; listView.SubDirTip_MenuItemClicked += subDirTip_MenuItemClicked; listView.SubDirTip_MenuItemRightClicked += subDirTip_MenuItemRightClicked; listView.SubDirTip_MultipleMenuItemsClicked += subDirTip_MultipleMenuItemsClicked; listView.SubDirTip_MultipleMenuItemsRightClicked += subDirTip_MultipleMenuItemsRightClicked; } } } return PInvoke.CallNextHookEx(IntPtr.Zero, nCode, wParam, lParam); }
internal ExtendedItemsView(ShellBrowserEx ShellBrowser, IntPtr hwndShellView, IntPtr hwndListView, IntPtr hwndSubDirTipMessageReflect) : base(ShellBrowser, hwndShellView, hwndListView, hwndSubDirTipMessageReflect) { }
internal ExtendedSysListView32(ShellBrowserEx ShellBrowser, IntPtr hwndShellView, IntPtr hwndListView, IntPtr hwndSubDirTipMessageReflect) : base(ShellBrowser, hwndShellView, hwndListView, hwndSubDirTipMessageReflect) { SetStyleFlags(); }
internal ExtendedItemsView(ShellBrowserEx ShellBrowser, IntPtr hwndShellView, IntPtr hwndListView, IntPtr hwndSubDirTipMessageReflect) : base(ShellBrowser, hwndShellView, hwndListView, hwndSubDirTipMessageReflect) { BandObjectLib.Logging.Add_DEBUG("Constructor.log", "ExtendedItemsView"); }
public override void CloseDW(uint dwReserved) { try { if(treeViewWrapper != null) { treeViewWrapper.Dispose(); treeViewWrapper = null; } if(listViewManager != null) { listViewManager.Dispose(); listViewManager = null; } if(subDirTip_Tab != null) { subDirTip_Tab.Dispose(); subDirTip_Tab = null; } if(IsShown) { if(pluginServer != null) { pluginServer.Dispose(); pluginServer = null; } if(hHook_Key != IntPtr.Zero) { PInvoke.UnhookWindowsHookEx(hHook_Key); hHook_Key = IntPtr.Zero; } if(hHook_Mouse != IntPtr.Zero) { PInvoke.UnhookWindowsHookEx(hHook_Mouse); hHook_Mouse = IntPtr.Zero; } if(hHook_Msg != IntPtr.Zero) { PInvoke.UnhookWindowsHookEx(hHook_Msg); hHook_Msg = IntPtr.Zero; } if(explorerController != null) { explorerController.ReleaseHandle(); explorerController = null; } if(rebarController != null) { rebarController.Dispose(); rebarController = null; } if(!QTUtility.IsXP && (travelBtnController != null)) { travelBtnController.ReleaseHandle(); travelBtnController = null; } InstanceManager.RemoveFromTrayIcon(Handle); // TODO: check this using(RegistryKey key = Registry.CurrentUser.CreateSubKey(RegConst.Root)) { if(Config.Misc.KeepHistory) { foreach(QTabItem item in tabControl1.TabPages) { AddToHistory(item); } QTUtility.SaveRecentlyClosed(key); } if(Config.Misc.KeepRecentFiles) { QTUtility.SaveRecentFiles(key); } string[] list = (from QTabItem item2 in tabControl1.TabPages where item2.TabLocked select item2.CurrentPath).ToArray(); QTUtility2.WriteRegBinary(list, "TabsLocked", key); InstanceManager.UnregisterTabBar(); if(0x80000 != ((int)PInvoke.Ptr_OP_AND(PInvoke.GetWindowLongPtr(ExplorerHandle, -20), 0x80000))) { QTUtility.WindowAlpha = 0xff; } else { byte num; int num2; int num3; if(PInvoke.GetLayeredWindowAttributes(ExplorerHandle, out num2, out num, out num3)) { QTUtility.WindowAlpha = num; } else { QTUtility.WindowAlpha = 0xff; } } key.SetValue("WindowAlpha", QTUtility.WindowAlpha); IDLWrapper.SaveCache(key); } if((md5Form != null) && !md5Form.InvokeRequired) { md5Form.SaveMD5FormStat(); md5Form.Dispose(); md5Form = null; } Cursor = Cursors.Default; if((curTabDrag != null) && (curTabDrag != Cursors.Default)) { PInvoke.DestroyIcon(curTabDrag.Handle); GC.SuppressFinalize(curTabDrag); curTabDrag = null; } if((curTabCloning != null) && (curTabCloning != Cursors.Default)) { PInvoke.DestroyIcon(curTabCloning.Handle); GC.SuppressFinalize(curTabCloning); curTabCloning = null; } if(dropTargetWrapper != null) { dropTargetWrapper.Dispose(); dropTargetWrapper = null; } OptionsDialog.ForceClose(); if(tabSwitcher != null) { tabSwitcher.Dispose(); tabSwitcher = null; } } if(TravelLog != null) { Marshal.FinalReleaseComObject(TravelLog); TravelLog = null; } if(shellContextMenu != null) { shellContextMenu.Dispose(); shellContextMenu = null; } if(ShellBrowser != null) { ShellBrowser.Dispose(); ShellBrowser = null; } foreach(ITravelLogEntry entry in LogEntryDic.Values) { if(entry != null) { Marshal.FinalReleaseComObject(entry); } } LogEntryDic.Clear(); fFinalRelease = true; base.CloseDW(dwReserved); } catch(Exception exception2) { QTUtility2.MakeErrorLog(exception2, "tabbar closing"); } }
internal ExtendedSysListView32(ShellBrowserEx ShellBrowser, IntPtr hwndShellView, IntPtr hwndListView, IntPtr hwndSubDirTipMessageReflect) : base(ShellBrowser, hwndShellView, hwndListView, hwndSubDirTipMessageReflect) { SetStyleFlags(); BandObjectLib.Logging.Add_DEBUG("Constructor.log", "ExtendedSysListView32"); }
internal ExtendedItemsView(ShellBrowserEx ShellBrowser, IntPtr hwndShellView, IntPtr hwndListView, IntPtr hwndSubDirTipMessageReflect, AutomationManager AutoMan) : base(ShellBrowser, hwndShellView, hwndListView, hwndSubDirTipMessageReflect) { this.AutoMan = AutoMan; }
private void GetFolderView() { // desktop thread const int SWC_DESKTOP = 0x00000008; const int SWFO_NEEDDISPATCH = 0x00000001; SHDocVw.ShellWindows shellWindows = null; try { shellWindows = new SHDocVw.ShellWindows(); object oNull1 = null, oNull2 = null; int pHWND; object o = shellWindows.FindWindowSW(ref oNull1, ref oNull2, SWC_DESKTOP, out pHWND, SWFO_NEEDDISPATCH); _IServiceProvider sp = o as _IServiceProvider; if(sp == null) return; object oShellBrowser; sp.QueryService(ExplorerGUIDs.IID_IShellBrowser, ExplorerGUIDs.IID_IUnknown, out oShellBrowser); ShellBrowser = new ShellBrowserEx(oShellBrowser as IShellBrowser); } catch { } finally { if(shellWindows != null) { Marshal.ReleaseComObject(shellWindows); } } }
private static ToolStripItem CreateMenuItem_AppLauncher(UserApp app, EventPack ep, ShellBrowserEx shellBrowser) { string path = app.Path; try { path = Environment.ExpandEnvironmentVariables(path); } catch { } MenuItemArguments mia = new MenuItemArguments(app, shellBrowser, MenuGenre.Application); if (path.StartsWith(@"\\") || path.StartsWith("::") || !Directory.Exists(path)) { mia.Target = MenuTarget.File; QMenuItem item = new QMenuItem(app.Name, mia) { Name = app.Name }; item.SetImageReservationKey(path, Path.GetExtension(path)); item.MouseMove += qmi_File_MouseMove; if (!ep.FromTaskBar && app.ShortcutKey != Keys.None) { item.ShortcutKeyDisplayString = QTUtility2.MakeKeyString(app.ShortcutKey).Replace(" ", string.Empty); } return(item); } else { mia.Target = MenuTarget.Folder; DropDownMenuReorderable reorderable = new DropDownMenuReorderable(null) { MessageParent = ep.MessageParentHandle, ImageList = QTUtility.ImageListGlobal }; reorderable.ItemRightClicked += ep.ItemRightClickEventHandler; DirectoryMenuItem item = new DirectoryMenuItem(app.Name) { Name = app.Name, Path = path, MenuItemArguments = mia, EventPack = ep, ModifiedDate = Directory.GetLastWriteTime(path), DropDown = reorderable, DoubleClickEnabled = true }; item.DropDownItems.Add(new ToolStripMenuItem()); item.DropDownItemClicked += realDirectory_DropDownItemClicked; item.DropDownOpening += realDirectory_DropDownOpening; item.DoubleClick += ep.DirDoubleClickEventHandler; item.SetImageReservationKey(path, null); return(item); } }
private static ToolStripItem CreateMenuItem_AppLauncher(UserApp app, EventPack ep, ShellBrowserEx shellBrowser) { string path = app.Path; try { path = Environment.ExpandEnvironmentVariables(path); } catch { } MenuItemArguments mia = new MenuItemArguments(app, shellBrowser, MenuGenre.Application); if(path.StartsWith(@"\\") || path.StartsWith("::") || !Directory.Exists(path)) { mia.Target = MenuTarget.File; QMenuItem item = new QMenuItem(app.Name, mia) { Name = app.Name }; item.SetImageReservationKey(path, Path.GetExtension(path)); item.MouseMove += qmi_File_MouseMove; if(!ep.FromTaskBar && app.ShortcutKey != Keys.None) { item.ShortcutKeyDisplayString = QTUtility2.MakeKeyString(app.ShortcutKey).Replace(" ", string.Empty); } return item; } else { mia.Target = MenuTarget.Folder; DropDownMenuReorderable reorderable = new DropDownMenuReorderable(null) { MessageParent = ep.MessageParentHandle, ImageList = QTUtility.ImageListGlobal }; reorderable.ItemRightClicked += ep.ItemRightClickEventHandler; DirectoryMenuItem item = new DirectoryMenuItem(app.Name) { Name = app.Name, Path = path, MenuItemArguments = mia, EventPack = ep, ModifiedDate = Directory.GetLastWriteTime(path), DropDown = reorderable, DoubleClickEnabled = true }; item.DropDownItems.Add(new ToolStripMenuItem()); item.DropDownItemClicked += realDirectory_DropDownItemClicked; item.DropDownOpening += realDirectory_DropDownOpening; item.DoubleClick += ep.DirDoubleClickEventHandler; item.SetImageReservationKey(path, null); return item; } }
protected override void OnExplorerAttached() { ExplorerHandle = (IntPtr)Explorer.HWND; try { object obj2; object obj3; _IServiceProvider bandObjectSite = (_IServiceProvider)BandObjectSite; bandObjectSite.QueryService(ExplorerGUIDs.IID_IShellBrowser, ExplorerGUIDs.IID_IUnknown, out obj2); ShellBrowser = new ShellBrowserEx((IShellBrowser)obj2); HookLibManager.InitShellBrowserHook(ShellBrowser.GetIShellBrowser()); if(Config.Tweaks.ForceSysListView) { ShellBrowser.SetUsingListView(true); } bandObjectSite.QueryService(ExplorerGUIDs.IID_ITravelLogStg, ExplorerGUIDs.IID_ITravelLogStg, out obj3); TravelLog = (ITravelLogStg)obj3; } catch(COMException exception) { QTUtility2.MakeErrorLog(exception); } Explorer.BeforeNavigate2 += Explorer_BeforeNavigate2; Explorer.NavigateComplete2 += Explorer_NavigateComplete2; }
protected override void OnExplorerAttached() { ExplorerHandle = (IntPtr)Explorer.HWND; if(QTUtility.CheckConfig(Settings.NoWindowResizing)) { PInvoke.SetWindowLongPtr(ExplorerHandle, -16, PInvoke.Ptr_OP_AND(PInvoke.GetWindowLongPtr(ExplorerHandle, -16), 0xfffbffff)); } try { object obj2; object obj3; _IServiceProvider bandObjectSite = (_IServiceProvider)BandObjectSite; Guid guid = ExplorerGUIDs.IID_IShellBrowser; Guid riid = ExplorerGUIDs.IID_IUnknown; bandObjectSite.QueryService(ref guid, ref riid, out obj2); ShellBrowser = new ShellBrowserEx((IShellBrowser)obj2); QTUtility.InitShellBrowserHook(ShellBrowser.GetIShellBrowser()); if(QTUtility.CheckConfig(Settings.ForceSysListView)) { ShellBrowser.SetUsingListView(true); } Guid guid3 = ExplorerGUIDs.IID_ITravelLogStg; Guid guid4 = ExplorerGUIDs.IID_ITravelLogStg; bandObjectSite.QueryService(ref guid3, ref guid4, out obj3); TravelLog = (ITravelLogStg)obj3; } catch(COMException exception) { QTUtility2.MakeErrorLog(exception, null); } Explorer.BeforeNavigate2 += Explorer_BeforeNavigate2; Explorer.NavigateComplete2 += Explorer_NavigateComplete2; }
public override void CloseDW(uint dwReserved) { try { if(treeViewWrapper != null) { treeViewWrapper.Dispose(); treeViewWrapper = null; } if(listViewManager != null) { listViewManager.Dispose(); listViewManager = null; } if(subDirTip_Tab != null) { subDirTip_Tab.Dispose(); subDirTip_Tab = null; } if(IsShown) { if(pluginManager != null) { pluginManager.Close(false); pluginManager = null; } if(hHook_Key != IntPtr.Zero) { PInvoke.UnhookWindowsHookEx(hHook_Key); hHook_Key = IntPtr.Zero; } if(hHook_Mouse != IntPtr.Zero) { PInvoke.UnhookWindowsHookEx(hHook_Mouse); hHook_Mouse = IntPtr.Zero; } if(hHook_Msg != IntPtr.Zero) { PInvoke.UnhookWindowsHookEx(hHook_Msg); hHook_Msg = IntPtr.Zero; } if(explorerController != null) { explorerController.ReleaseHandle(); explorerController = null; } if(rebarController != null) { rebarController.ReleaseHandle(); rebarController = null; } if(!QTUtility.IsXP && (travelBtnController != null)) { travelBtnController.ReleaseHandle(); travelBtnController = null; } if(dicNotifyIcon != null) { dicNotifyIcon.Remove(ExplorerHandle); } if((hwndNotifyIconParent == ExplorerHandle) && (notifyIcon != null)) { notifyIcon.Dispose(); notifyIcon = null; contextMenuNotifyIcon.Dispose(); contextMenuNotifyIcon = null; hwndNotifyIconParent = IntPtr.Zero; if(dicNotifyIcon.Count > 0) { foreach(IntPtr ptr in dicNotifyIcon.Keys) { IntPtr tabBarHandle = QTUtility.instanceManager.GetTabBarHandle(ptr); if(1 == ((int)QTUtility2.SendCOPYDATASTRUCT(tabBarHandle, (IntPtr)0x30, "createNI", IntPtr.Zero))) { break; } } } } using(RegistryKey key = Registry.CurrentUser.CreateSubKey(@"Software\Quizo\QTTabBar")) { if(!QTUtility.CheckConfig(Settings.NoHistory)) { foreach(QTabItem item in tabControl1.TabPages) { AddToHistory(item); } QTUtility.SaveRecentlyClosed(key); } if(!QTUtility.CheckConfig(Settings.NoRecentFiles) && QTUtility.CheckConfig(Settings.AllRecentFiles)) { QTUtility.SaveRecentFiles(key); } string[] list = (from QTabItem item2 in tabControl1.TabPages where item2.TabLocked select item2.CurrentPath).ToArray(); QTUtility2.WriteRegBinary(list, "TabsLocked", key); key.SetValue("StartUpGroups", QTUtility.StartUpGroupList.StringJoin(";")); if(QTUtility.instanceManager.RemoveInstance(ExplorerHandle, this)) { QTUtility.instanceManager.NextInstanceExists(); QTUtility2.WriteRegHandle("Handle", key, QTUtility.instanceManager.CurrentHandle); } if(QTUtility.CheckConfig(Settings.SaveTransparency)) { if(0x80000 != ((int)PInvoke.Ptr_OP_AND(PInvoke.GetWindowLongPtr(ExplorerHandle, -20), 0x80000))) { QTUtility.WindowAlpha = 0xff; } else { byte num; int num2; int num3; if(PInvoke.GetLayeredWindowAttributes(ExplorerHandle, out num2, out num, out num3)) { QTUtility.WindowAlpha = num; } else { QTUtility.WindowAlpha = 0xff; } } key.SetValue("WindowAlpha", QTUtility.WindowAlpha); } IDLWrapper.SaveCache(key); } if((md5Form != null) && !md5Form.InvokeRequired) { md5Form.SaveMD5FormStat(); md5Form.Dispose(); md5Form = null; } Cursor = Cursors.Default; if((curTabDrag != null) && (curTabDrag != Cursors.Default)) { PInvoke.DestroyIcon(curTabDrag.Handle); GC.SuppressFinalize(curTabDrag); curTabDrag = null; } if((curTabCloning != null) && (curTabCloning != Cursors.Default)) { PInvoke.DestroyIcon(curTabCloning.Handle); GC.SuppressFinalize(curTabCloning); curTabCloning = null; } if(dropTargetWrapper != null) { dropTargetWrapper.Dispose(); dropTargetWrapper = null; } if((optionsDialog != null) && fOptionDialogCreated) { fOptionDialogCreated = false; try { optionsDialog.Invoke(new MethodInvoker(odCallback_Close)); } catch(Exception exception) { QTUtility2.MakeErrorLog(exception, "optionDialogDisposing"); } } if(tabSwitcher != null) { tabSwitcher.Dispose(); tabSwitcher = null; } } QTUtility.InstancesCount--; if(TravelLog != null) { Marshal.FinalReleaseComObject(TravelLog); TravelLog = null; } if(iContextMenu2 != null) { Marshal.FinalReleaseComObject(iContextMenu2); iContextMenu2 = null; } if(ShellBrowser != null) { ShellBrowser.Dispose(); ShellBrowser = null; } foreach(ITravelLogEntry entry in LogEntryDic.Values) { if(entry != null) { Marshal.FinalReleaseComObject(entry); } } LogEntryDic.Clear(); if(bmpRebar != null) { bmpRebar.Dispose(); bmpRebar = null; } if(textureBrushRebar != null) { textureBrushRebar.Dispose(); textureBrushRebar = null; } fFinalRelease = true; base.CloseDW(dwReserved); } catch(Exception exception2) { QTUtility2.MakeErrorLog(exception2, "tabbar closing"); } }
public static void Execute(UserApp app, ShellBrowserEx shellBrowser) { // todo validate app string pathCurrent; using (IDLWrapper wrapper = shellBrowser.GetShellPath()) { pathCurrent = wrapper.Path; } Address[] selection; shellBrowser.TryGetSelection(out selection, false); List <string> lstFiles = new List <string>(); List <string> lstDirs = new List <string>(); if (selection != null) { foreach (Address address in selection) { using (IDLWrapper wrapper = new IDLWrapper(address.ITEMIDLIST)) { if (!wrapper.Available || !wrapper.HasPath) { continue; } (wrapper.IsFileSystemFile ? lstFiles : lstDirs).Add(address.Path.TrimEnd('\\').Enquote()); } } } string strFiles = lstFiles.StringJoin(" "); string strDirs = lstDirs.StringJoin(" "); string strBoth = (strFiles + " " + strDirs).Trim(); pathCurrent = Directory.Exists(pathCurrent) ? pathCurrent.TrimEnd('\\').Enquote() : ""; string args = app.Args; string work = app.WorkingDir; string path = app.Path; string[] variableValues = { strDirs.Length > 0 ? strDirs : pathCurrent, // %cd% pathCurrent, // %c% strDirs, // %d% strFiles, // %f% strBoth // %s% }; for (int i = 0; i < variableValues.Length; i++) { args = reVariables[i].Replace(args, variableValues[i]); } variableValues = new string[] { lstDirs.Count > 0 ? lstDirs[0] : pathCurrent, // %cd% pathCurrent, // %c% lstDirs.Count > 0 ? lstDirs[0] : "", // %d% "", // %f% lstDirs.Count > 0 ? lstDirs[0] : "" // %s% }; for (int i = 0; i < variableValues.Length; i++) { work = reVariables[i].Replace(work, variableValues[i]); } const int SW_SHOWNORMAL = 1; const int SEE_MASK_IDLIST = 0x00000004; const int SEE_MASK_DOENVSUBST = 0x00000200; // Expand any environment variables specified in the string given by the lpDirectory or lpFile const int SEE_MASK_ASYNCOK = 0x00100000; const int SEE_MASK_FLAG_LOG_USAGE = 0x04000000; // Open NameSpace folder. if (path.StartsWith(IDLWrapper.INDICATOR_NAMESPACE)) { using (IDLWrapper idlw = new IDLWrapper(path)) { if (idlw.Available) { SHELLEXECUTEINFO sei = new SHELLEXECUTEINFO { cbSize = Marshal.SizeOf(typeof(SHELLEXECUTEINFO)), nShow = SW_SHOWNORMAL, fMask = SEE_MASK_IDLIST, lpIDList = idlw.PIDL, hwnd = shellBrowser.GetExplorerHandle() }; PInvoke.ShellExecuteEx(ref sei); return; } } } else { // check whether target exists if link using (IDLWrapper idlw = new IDLWrapper(path)) { if (idlw.IsLinkToDeadFolder) { return; } } SHELLEXECUTEINFO sei = new SHELLEXECUTEINFO { cbSize = Marshal.SizeOf(typeof(SHELLEXECUTEINFO)), nShow = SW_SHOWNORMAL, fMask = SEE_MASK_DOENVSUBST | SEE_MASK_FLAG_LOG_USAGE | SEE_MASK_ASYNCOK, hwnd = shellBrowser.GetExplorerHandle() }; try { sei.lpFile = Marshal.StringToCoTaskMemUni(path); // Arguments if (!string.IsNullOrEmpty(args)) { sei.lpParameters = Marshal.StringToCoTaskMemUni(args); } // Working directory if (!string.IsNullOrEmpty(work)) { work = work.Trim(new char[] { '"', '\'' }); sei.lpDirectory = Marshal.StringToCoTaskMemUni(work); } else { // "::" will cause an exception in Path.GetDirectoryName if (QTUtility2.IsExecutable(Path.GetExtension(path)) && !path.StartsWith(IDLWrapper.INDICATOR_NAMESPACE)) { work = Path.GetDirectoryName(path); } if (!string.IsNullOrEmpty(work)) { sei.lpDirectory = Marshal.StringToCoTaskMemUni(work); } } if (PInvoke.ShellExecuteEx(ref sei)) { StaticReg.ExecutedPathsList.Add(path); return; } } finally { if (sei.lpFile != IntPtr.Zero) { Marshal.FreeCoTaskMem(sei.lpFile); } if (sei.lpParameters != IntPtr.Zero) { Marshal.FreeCoTaskMem(sei.lpParameters); } if (sei.lpDirectory != IntPtr.Zero) { Marshal.FreeCoTaskMem(sei.lpDirectory); } } } // Show Error Message. if (!String.IsNullOrEmpty(args)) { path += ", " + args; } if (!String.IsNullOrEmpty(work)) { path += ", " + work; } MessageBox.Show( String.Format(QTUtility.TextResourcesDic["ErrorDialogs"][0], path), QTUtility.TextResourcesDic["ErrorDialogs"][1], MessageBoxButtons.OK, MessageBoxIcon.Error ); }