Windowsフォルダオプションの設定を実装しているWPF C#プロジェクトがあります。そのうちの1つは、ダブルクリックの代わりに「アイテムを開くためのシングルクリック」です。レジストリキーを変更すると、解決策を見つけたWindowsエクスプローラを更新する必要があります。しかし、デスクトップはリフレッシュされず、手動でリフレッシュしても変更は適用されません。 私はIActiveDesktop :: ApplyChangesメソッドを使用しましたが、機能しませんでした(または多分私は間違いを犯しました)。また、私は、このコードスニペットを使用しましたが、それはまだ私が行った変更を適用しません。デスクトップをリフレッシュ/リロードする方法
SHChangeNotify(0x8000000, 0x1000, IntPtr.Zero, IntPtr.Zero);
そして、ここでは、私が勝つExplorerをリフレッシュするために使用完全なコードスニペットです(魔女はこのサイトからです):Windowsエクスプローラではなく、デスクトップがあまりにもエクスプローラに依存するため、奇数のデスクトップ()のために働く
[System.Runtime.InteropServices.DllImport("Shell32.dll")]
private static extern int SHChangeNotify(int eventId, int flags, IntPtr item1, IntPtr item2);
public static void RefreshWindowsExplorer()
{
// Refresh the desktop
SHChangeNotify(0x8000000, 0x1000, IntPtr.Zero, IntPtr.Zero);
// Refresh any open explorer windows
// based on http://stackoverflow.com/questions/2488727/refresh-windows-explorer-in-win7
Guid CLSID_ShellApplication = new Guid("13709620-C279-11CE-A49E-444553540000");
Type shellApplicationType = Type.GetTypeFromCLSID(CLSID_ShellApplication, true);
object shellApplication = Activator.CreateInstance(shellApplicationType);
object windows = shellApplicationType.InvokeMember("Windows", System.Reflection.BindingFlags.InvokeMethod, null, shellApplication, new object[] { });
Type windowsType = windows.GetType();
object count = windowsType.InvokeMember("Count", System.Reflection.BindingFlags.GetProperty, null, windows, null);
for (int i = 0; i < (int)count; i++)
{
object item = windowsType.InvokeMember("Item", System.Reflection.BindingFlags.InvokeMethod, null, windows, new object[] { i });
Type itemType = item.GetType();
// Only refresh Windows Explorer, without checking for the name this could refresh open IE windows
string itemName = (string)itemType.InvokeMember("Name", System.Reflection.BindingFlags.GetProperty, null, item, null);
if (itemName == "Windows Explorer")
{
itemType.InvokeMember("Refresh", System.Reflection.BindingFlags.InvokeMethod, null, item, null);
}
}
}
。 変更を有効にするには、デスクトップを再ロードする必要がありますか?
すべてのエクスプローラインスタンスを終了して新しいインスタンスを作成しようとするとどうなりますか? – master131
@ master131、それは動作しますが、ユーザーはすべてのエクスプローラウィンドウを失うので、オプションではありません。 – SepehrM
[デスクトップアイコンの表示/非表示]を有効にするにはどうすればよいですか?](http://stackoverflow.com/questions/3326062/how-do-i-make-the-show-hide-desktop -icons-setting-take-effect) –