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

public static void UnZip(string zipFile, string folderPath)
        {
            if (!Directory.Exists(folderPath))
                Directory.CreateDirectory(folderPath);

            Shell32.Shell objShell = new Shell32.Shell();
            Shell32.Folder destinationFolder = objShell.NameSpace(folderPath);
            Shell32.Folder sourceFile = objShell.NameSpace(zipFile);

            foreach (var file in sourceFile.Items())
            {
                destinationFolder.CopyHere(file, 4 | 16);
            }
        }

Example 3: shell32.dll c# example

public static string GetLnkTarget(string lnkPath)
 {
     try
     {
         var shl = new Shell32.Shell();         // Move this to class scope
         var dir = shl.NameSpace(System.IO.Path.GetDirectoryName(lnkPath));
         var itm = dir.Items().Item(System.IO.Path.GetFileName(lnkPath));
         var lnk = (Shell32.ShellLinkObject)itm.GetLink;
         return lnk.Target.Path;
     }
     catch (Exception)
     {
         return lnkPath;
     }
 }

Example 4: shell32.dll c# example

public void ZipFile(string Input, string Filename)
    {
        Shell32.Shell Shell = new Shell32.Shell();
        
        //Create our Zip File
        CreateZipFile(Filename);

        //Copy the file or folder to it
        Shell.NameSpace(Filename).CopyHere(Input,0);
          
        //If you can write the code to wait for the code to finish, please let me know
        System.Threading.Thread.Sleep(2000);

        }
    }

Example 5: shell32.dll c# example

public Main()
        {
            InitializeComponent();
            //
            // TODO: Add any constructor code after InitializeComponent call
            //
            SplitView.SplitPosition = this.Width / 2;

            m_Shell = new Shell32.ShellClass();
            m_RootShell = m_Shell.NameSpace(Shell32.ShellSpecialFolderConstants.ssfDRIVES);

            InitializeIconFolder();
            FillLocalView(m_RootShell);
        }

Example 6: shell32.dll c# example

public static void ZipFile(string Input, string Filename)
        {
            Shell32.Shell Shell = new Shell32.Shell();

            //Create our Zip File
            CreateZipFile(Filename);

            //Copy the file or folder to it
            Shell.NameSpace(Filename).CopyHere(Input, 0);

            //If you can write the code to wait for the code to finish, please let me know
            System.Threading.Thread.Sleep(1000);
        }