C# と VB.NET の質問掲示板

ASP.NET、C++/CLI、Java 何でもどうぞ

ログ内検索
  • キーワードを複数指定する場合は 半角スペース で区切ってください。
  • 検索条件は、(AND)=[A かつ B] (OR)=[A または B] となっています。
  • [返信]をクリックすると返信ページへ移動します。
キーワード/ 検索条件 /
検索範囲/ 強調表示/ ON (自動リンクOFF)
結果表示件数/ 記事No検索/ ON
大文字と小文字を区別する

No.88499 の関連記事表示

<< 0 >>
■88499  Re[2]: 任意のエクスプローラ(フォルダ)を閉じたい
□投稿者/ Ante -(2018/09/04(Tue) 11:51:51)
    No88494 (魔界の仮面弁士 さん) に返信
    ありがとうございます。これで要件を満たせます。
    
    よろしければ、もう一つだけ可能でしたらお知らせいただけますか、
    
    以下の記事を投稿したのも私なのですが、
    「Windows10 C# エクスプローラー フォルダのレイアウト中アイコン設定」
    http://bbs.wankuma.com/search.cgi?no=0&word=%92%86%83A%83C%83R%83%93&andor=and&logs=.%2Fpost.dat&PAGE=20
    
    教示頂いた以下のコードを参考にさせていただきました。
    
    このコードは現在アクティブであるエクスプローラ上のアイコンを中アイコンに設定するかと思いますが、
    これをアクティブでない任意のフォルダを中アイコンに設定することは可能なのでしょうか。
    
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Windows.Forms;
    using System.Runtime.InteropServices;
    using System.IO;
    
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
    
        private void Form1_Load(object sender, EventArgs e)
        {
            var sizes = new Dictionary<uint, string>
            {
                {256u, "特大"},
                {96u, "大"},
                {48u, "中"},
                {16u, "小"},
            };
    
            comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
            comboBox1.DataSource = sizes.ToArray();
            comboBox1.ValueMember = "Key";
            comboBox1.DisplayMember = "Value";
            comboBox1.SelectedIndex = 2;
        }
    
        private void button1_Click(object sender, EventArgs e)
        {
            foreach (var w in GetExplorer())
            {
                if(Confirm(w.Path, w.LocationName))
                {
                    var sfv = w.Document;
                    sfv.CurrentViewMode = 1u;
                    sfv.IconSize = comboBox1.SelectedValue;
                    Marshal.ReleaseComObject(sfv);
                }
            }
        }
    
        private bool Confirm(string path, string location)
        {
            return DialogResult.Yes == MessageBox.Show(
                this,
                "このフォルダのアイコンサイズを変更しますか?\r\n" + location + "\r\n" + path,
                "確認",
                MessageBoxButtons.YesNo,
                MessageBoxIcon.Question,
                MessageBoxDefaultButton.Button2);
        }
    
        private IEnumerable<dynamic> GetExplorer()
        {
            dynamic exp = Activator.CreateInstance(Type.GetTypeFromCLSID(Guid.Parse("{9BA05972-F6A8-11CF-A442-00A0C90A8F39}")));
            System.Runtime.InteropServices.ComTypes.IEnumVARIANT f = exp._NewEnum;
            object[] varRes = new object[1];
            while (f.Next(1, varRes, IntPtr.Zero) == 0)
            {
                dynamic w = varRes.FirstOrDefault();
                if (w != null)
                {
                    if (Path.GetFileName(w.FullName).ToLowerInvariant() == "explorer.exe")
                    {
                        yield return w;
                    }
                    if (Marshal.IsComObject(w))
                    {
                        Marshal.ReleaseComObject(w);
                    }
                }
            }
            if(Marshal.IsComObject(f))
            {
                Marshal.ReleaseComObject(f);
            }
            Marshal.ReleaseComObject(exp);
        }
    }
    
    
記事No.88492 のレス /過去ログ153より / 関連記事表示
削除チェック/



<< 0 >>

パスワード/

- Child Tree -