Windows 탐색기를 새로 고치려면 this thread을 참조하고 있습니다. 일부 창만 새로 고침합니다. 즉, 제목이나 경로에 따라 열린 창을 필터링하려고합니다. 이 라인 windowsType.InvokeMember("Item", System.Reflection.BindingFlags.InvokeMethod, null, windows, new object[] { i });
를 사용하여 우리는 현재 창 개체를 얻을 것이다, 그리고 우리가 얻을 .InvokeMember("Name"..
를 사용 : 나는 위의 코드를 이해 무엇특정 속성 값을 가져올 수있는 InvokeMember의 가능한 값
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();
string itemName = (string)itemType.InvokeMember("Name", System.Reflection.BindingFlags.GetProperty, null, item, null);
if (itemName == "Windows Explorer")
{
// Here I want to check whether this window need to be refreshed
// based on the opened path in that window
// or with the title of that window
// How do I check that here
itemType.InvokeMember("Refresh", System.Reflection.BindingFlags.InvokeMethod, null, item, null);
}
}
입니다 : 좀 더 명확한 설명을 위해 해당 스레드에서 코드를 복사하자 해당 객체의 이름, 현명한 것처럼 내가 그 객체의 경로 또는 해당 창의 제목을 얻으려면 InvokeMember
메서드에 전달해야합니까? 또는 누가 위의 진술에 "Name"
에 대한 가능한 대체 값을 말해 줄 수 있습니까?
string itemPath = (string)itemType.InvokeMember("Something here", System.Reflection.BindingFlags.GetProperty, null, item, null);
또는
string itemTitle = (string)itemType.InvokeMember("Something here", System.Reflection.BindingFlags.GetProperty, null, item, null);
당신이 필요하면이 문제를 해결하기 위해 전문가의 제안을 기대하고, 더 많은 정보를 제공 할 수 있습니다,
:내가 기대하고있어 다음과 같은 몇 가지 코드는
미리 감사드립니다.
감사합니다. 선생님, 15 번 받으면 upvote하겠습니다. – Learning