c# using shell32.dll code example

Example 1: shell32.dll c# example

public void                     onStartup()
        {
            Shell32.Shell               shell = new Shell32.Shell();
            Shell32.Folder              objFolder = shell.NameSpace(@"C:\Windows");

            this.files.Clear();
            foreach (string name in ColumnListPerName)
                this.files.Columns.Add(name);
            foreach (int id in ColumnListPerID)
            {
                string header = objFolder.GetDetailsOf(null, id);
                if (String.IsNullOrEmpty(header))
                    break;
                while (this.files.Columns.Contains(header))
                    header += "_";
                header = header.Replace("'", "_").Replace("’", "_");
                Debug.WriteLine("creating column named " + header);
                this.files.Columns.Add(header);
            }

            this.files.Columns["ID"].DataType = Type.GetType("System.Int32");
            this.files.Columns[objFolder.GetDetailsOf(null, 26).Replace("'", "_").Replace("’", "_")].DataType = Type.GetType("System.Int32");
            //this.files.Columns["Longueur"].DataType = Type.GetType("System.TimeSpan");
            this.files.Columns["URI"].DataType = typeof(System.Uri);
            ProcessLibraries();
            this.files.AcceptChanges();
        }

Example 2: shell32.dll c# example

private static void advanceBackgroundSlider()
 {
     //Display the Desktop via the COM component Shell32.dll
     Shell32.Shell objShell = new Shell32.Shell();
     objShell.ToggleDesktop();
     // Simulate Ctrl + Space to deselect anything that may be selected
     SendKeys.SendWait("^( )");
     // Simulate pressing Shift + F10 to open Desktop context menu
     SendKeys.SendWait("+{F10}");
     // Simulate pressing N to execute the “Next desktop background” command
     SendKeys.SendWait("{N}");
 }

Example 3: shell32.dll c# example

public static bool CopyFontToWindowsFontFolder(string fontFilePath)
        {
            FileInfo fontFile = new FileInfo(fontFilePath);
            if (!fontFile.Exists)
                return false;

            var windowsFontFolderPath = Environment.GetFolderPath(Environment.SpecialFolder.Fonts);
            var shell = new Shell32.Shell();
            var destinationPath = Path.Combine(windowsFontFolderPath, Path.GetFileName(fontFilePath));
            var folder = shell.NameSpace(windowsFontFolderPath);
            folder.CopyHere(fontFilePath, 32);

            return true;
        }