/// <summary>Shows a folder selection dialog.</summary> /// <param name="title">The title to show on the dialog.</param> /// <param name="initDir">The start folder when the dialog opens or "" for last selected folder (default: Computer).</param> /// <returns>The full folder path after selection or "" when canceled, else "FAILED".</returns> public static Primitive SelectFolder(Primitive title, Primitive initDir) { string result = ""; string iDir = lastFolder; if (!String.IsNullOrEmpty(initDir)) { iDir = initDir; } if (!Directory.Exists(initDir)) { iDir = Environment.GetFolderPath(Environment.SpecialFolder.MyComputer); } try { Shell32.Shell shell = new Shell32.Shell(); Shell32.Folder2 fold = (Shell32.Folder2)shell.BrowseForFolder(0, (string)title, 0x10, (string)iDir); if (fold == null) { return(string.Empty); } result = fold.Self.Path; lastFolder = result; return(result); } catch { return("FAILED"); } }
// UNSURE if the returned values are really correct, resp. which values are returned at all from "1", "2", "4" etc. // http://msdn.microsoft.com/library/windows/desktop/gg537739.aspx Shell.GetSetting method /// <summary>Gets values for global Shell settings (s. folder opions-view, CheckedStatus).</summary> /// <param name="value">An integer constant for the value to get (eg. 1, 2, 4, "8", "32" etc.).</param> /// <returns>"True" or "False" on success, else "FAILED".</returns> /// <example>http://msdn.microsoft.com/library/windows/desktop/gg537739.aspx /// ShowAllObjects = SBShell.GetSetting(1) /// ShowExtensions = SBShell.GetSetting(2) /// ShowInfoTip = SBShell.GetSetting(8192) /// ShowSuperHidden = SBShell.GetSetting(262144)</example> public static Primitive GetSetting(Primitive value) { if (String.IsNullOrEmpty(value) || value < 1) { return("FAILED"); } try { // http://dotnetdud.blogspot.co.at/2008/10/convert-string-to-long-using-c.html // long longStr = Int64.Parse(value); // = Convert.ToInt64(value); Shell32.Shell shell = new Shell32.Shell(); return(shell.GetSetting(value)); // Convert.ToInt32((string)value, 16); } catch { return("FAILED"); } }
// http://msdn.microsoft.com/library/windows/desktop/gg537740.aspx Shell.GetSystemInformation method /// <summary>Gets a given Systeminformation.</summary> /// <param name="info">The name of the value to get. Options: /// "DirectoryServiceAvailable", "DoubleClickTime", "ProcessorLevel", "ProcessorSpeed", "ProcessorArchitecture", "PhysicalMemoryInstalled", "IsOS_DomainMember" /// (Only XP: "IsOS_Professional", "IsOS_Personal").</param> /// <returns>The queried value on success, else "" or "FAILED".</returns> public static Primitive GetSystemInfo(Primitive info) { string val = info; if (string.IsNullOrEmpty(val)) { return("FAILED"); } try { Shell32.Shell shell = new Shell32.Shell(); var objShell = shell; return(objShell.GetSystemInformation(val.Trim()).ToString()); } catch { return("FAILED"); } }
/// <summary>Opens explorer with the given file-/folder path (parent folder for existing file path). In new tab in QTTabBar.</summary> /// <param name="path">Opens the specified folder (file path opens parent folder). The folder must exist.</param> public static void OpenFolder(Primitive path) { string dir; if (String.IsNullOrEmpty(path)) { dir = Program.Directory; } else { dir = Environment.ExpandEnvironmentVariables(path); } if (System.IO.File.Exists(dir)) { dir = Path.GetDirectoryName(dir); } if (Directory.Exists(dir)) { Shell32.Shell shell = new Shell32.Shell(); shell.Open(dir); } }
/// <summary>Restores all minimized windows in the taskbar (after ShowDesktop, TileAll.., CascadeWindows) again.</summary> public static void RestoreWindows() { Shell32.Shell shell = new Shell32.Shell(); shell.UndoMinimizeALL(); }
// http://msdn.microsoft.com/library/windows/desktop/gg537740.aspx Shell.GetSystemInformation method /// <summary>Gets a given Systeminformation.</summary> /// <param name="info">The name of the value to get. Options: /// "DirectoryServiceAvailable", "DoubleClickTime", "ProcessorLevel", "ProcessorSpeed", "ProcessorArchitecture", "PhysicalMemoryInstalled", "IsOS_DomainMember" /// (Only XP: "IsOS_Professional", "IsOS_Personal").</param> /// <returns>The queried value on success, else "" or "FAILED".</returns> public static Primitive GetSystemInfo(Primitive info) { string val = info; if (string.IsNullOrEmpty(val)) return "FAILED"; try { Shell32.Shell shell = new Shell32.Shell(); var objShell = shell; return objShell.GetSystemInformation(val.Trim()).ToString(); } catch { return "FAILED"; } }
/// <summary>Opens explorer with the given file-/folder path (parent folder for existing file path). In new tab in QTTabBar.</summary> /// <param name="path">Opens the specified folder (file path opens parent folder). The folder must exist.</param> public static void OpenFolder(Primitive path) { string dir; if (String.IsNullOrEmpty(path)) dir = Program.Directory; else dir = Environment.ExpandEnvironmentVariables(path); if (System.IO.File.Exists(dir)) dir = Path.GetDirectoryName(dir); if (Directory.Exists(dir)) { Shell32.Shell shell = new Shell32.Shell(); shell.Open(dir); } }
/// <summary>Orders all opened windows vertically tiled on the desktop (Revert with RestoreWindows).</summary> public static void TileAllVert() { Shell32.Shell shell = new Shell32.Shell(); shell.TileVertically(); }
// UNSURE if the returned values are really correct, resp. which values are returned at all from "1", "2", "4" etc. // http://msdn.microsoft.com/library/windows/desktop/gg537739.aspx Shell.GetSetting method /// <summary>Gets values for global Shell settings (s. folder opions-view, CheckedStatus).</summary> /// <param name="value">An integer constant for the value to get (eg. 1, 2, 4, "8", "32" etc.).</param> /// <returns>"True" or "False" on success, else "FAILED".</returns> /// <example>http://msdn.microsoft.com/library/windows/desktop/gg537739.aspx /// ShowAllObjects = SBShell.GetSetting(1) /// ShowExtensions = SBShell.GetSetting(2) /// ShowInfoTip = SBShell.GetSetting(8192) /// ShowSuperHidden = SBShell.GetSetting(262144)</example> public static Primitive GetSetting(Primitive value) { if (String.IsNullOrEmpty(value) || value < 1) return "FAILED"; try { // http://dotnetdud.blogspot.co.at/2008/10/convert-string-to-long-using-c.html // long longStr = Int64.Parse(value); // = Convert.ToInt64(value); Shell32.Shell shell = new Shell32.Shell(); return shell.GetSetting(value); // Convert.ToInt32((string)value, 16); } catch { return "FAILED"; } }
/// <summary>Minimizes all opened windows into the taskbar and showes the desktop (Revert with RestoreWindows).</summary> public static void ShowDesktop() { Shell32.Shell shell = new Shell32.Shell(); shell.MinimizeAll(); }
/// <summary>Orders all opended windows in a 3D stack on the desktop to select through (with arrow keys).</summary> public static void Switch3D() { Shell32.Shell shell = new Shell32.Shell(); shell.WindowSwitcher(); }
/// <summary>Shows the dialog for date- and time settings.</summary> public static void DateTimeSettings() { Shell32.Shell shell = new Shell32.Shell(); shell.SetTime(); }
/// <summary>Shows the dialog for startmenü/taskbar settings.</summary> public static void StartSettings() { Shell32.Shell shell = new Shell32.Shell(); shell.TrayProperties(); }
/// <summary>Shows the Run(box) Dialog.</summary> public static void RunBox() { Shell32.Shell shell = new Shell32.Shell(); shell.FileRun(); }
/// <summary>Toggles the view of the (windowless) desktop on and off (s. ShowDesktop/RestoreWindows).</summary> public static void ToggleDesktop() { Shell32.Shell shell = new Shell32.Shell(); shell.ToggleDesktop(); }
/// <summary>Orders all opended windows in cascades on the desktop (Revert with RestoreWindows).</summary> public static void CascadeWindows() { Shell32.Shell shell = new Shell32.Shell(); shell.CascadeWindows(); }
/// <summary>Shows a folder selection dialog.</summary> /// <param name="title">The title to show on the dialog.</param> /// <param name="initDir">The start folder when the dialog opens or "" for last selected folder (default: Computer).</param> /// <returns>The full folder path after selection or "" when canceled, else "FAILED".</returns> public static Primitive SelectFolder(Primitive title, Primitive initDir) { string result = ""; string iDir = lastFolder; if (!String.IsNullOrEmpty(initDir)) iDir = initDir; if (!Directory.Exists(initDir)) iDir = Environment.GetFolderPath(Environment.SpecialFolder.MyComputer); try { Shell32.Shell shell = new Shell32.Shell(); Shell32.Folder2 fold = (Shell32.Folder2)shell.BrowseForFolder(0, (string)title, 0x10, (string)iDir); if (fold == null) return string.Empty; result = fold.Self.Path; lastFolder = result; return result; } catch { return "FAILED"; } }
/// <summary>Orders all opened windows horizontally tiled on the desktop (Revert with RestoreWindows).</summary> public static void TileAllHoriz() { Shell32.Shell shell = new Shell32.Shell(); shell.TileHorizontally(); }