Windows 폴더 옵션에 대한 설정을 구현하는 WPF C# 프로젝트가 있습니다. 그 중 하나는 "두 번 클릭하는 대신 한 번 클릭하여 항목 열기"입니다. 그 문제에 대한 레지스트리 키를 변경하면 솔루션을 찾은 Windows Explorer를 새로 고쳐야합니다. 그러나 바탕 화면은 새로 고치지 않으며 수동으로 새로 고치기 만해도 변경 내용이 적용되지 않습니다. IActiveDesktop :: ApplyChanges 메서드를 사용했지만 작동하지 않았습니다 (또는 실수로). 나는이 코드를 사용했지만, 여전히 내가 변경 한 내용이 적용되지 않습니다 : 여기바탕 화면 새로 고침/새로 고침
SHChangeNotify(0x8000000, 0x1000, IntPtr.Zero, IntPtr.Zero);
내가 승리 탐색기 (마녀 새로 고침에 사용되는 전체 코드는이 사이트에서입니다을) :
[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);
}
}
}
Windows 탐색기에서는 작동하지만 데스크톱에서는 작동하지 않습니다. 데스크톱은 탐색기에 따라 다르므로 이상합니다. 변경 사항을 적용하려면 데스크탑을 어떻게 다시 불러 와야합니까?
모든 탐색기 인스턴스를 종료하고 새 탐색기 인스턴스를 만들려고하면 어떻게됩니까? – master131
@ master131 그게 작동하지만 사용자가 모든 탐색기 창을 잃게되므로 옵션이 아닙니다. – SepehrM
가능한 복제본 [바탕 화면 아이콘 표시/숨기기] 설정을 적용하려면 어떻게합니까?] (http://stackoverflow.com/questions/3326062/how-do-i-make-the-show-hide-desktop -icons-setting-take-effect) –