Can I get the ExecutablePath from a System.Management.EventArrivedEventArgs object?

StackOverflow https://stackoverflow.com/questions/2134121

  •  22-09-2019
  •  | 
  •  

문제

I'm using a System.Management.ManagementEventWatcher to get the process ID and executable path for a started process:

private void startWatcher_EventArrived(Object sender, EventArrivedEventArgs e)
{
    String processID = e.NewEvent.Properties["ProcessID"].Value.ToString();

    var searcher = new ManagementObjectSearcher(new WqlObjectQuery(String.Format("Select ExecutablePath from Win32_Process where ProcessID = {0}", processID)));

    ManagementObject managementObject = null;
    foreach (ManagementObject obj in searcher.Get())
    {
        managementObject = obj;
        break;
    }

    Console.WriteLine(managementObject["ExecutablePath"]);
}

Using this WQL Query:

Select ExecutablePath from Win32_ProcessStartTrace

Is there a way that I can avoid doing the object search, but still get the ExecutionPath, using what is already available in the EventArrivedEventArgs object?

All I really need is the ProcessID and the ExecuatblePath for each new process that starts up. Is this the simplest way to get that?

도움이 되었습니까?

해결책

No, what you got is as good as it gets. The available properties are listed here...

다른 팁

원하는보기가 문서 세트에서 일관되면 문서 세트 컨텐츠 유형을 구성 할 때 한 번 구성 할 수 있으며이 문서 세트의 모든 새 인스턴스가이를 반영합니다.

찾고있는 설정을 "환영 페이지"설정이라고합니다.

참조 : 새 문서 세트 만들기 및 구성 컨텐츠 유형

"문서 설정 컨텐츠 유형 설정"을 구성하거나 사용자 정의하는 제목 아래에서 10-12 단계 :

10) 시작 페이지 열 섹션에서 문서 세트의 시작 페이지에 표시 할 열을 지정합니다.

11) 환영 페이지 섹션에서 시작 페이지 을 클릭하여 문서 세트의 각 인스턴스에 대해 사용자에게 표시되는 시작 페이지의 모양을 사용자 정의하려면 를 클릭하십시오.

12)이 문서 세트에서 상속하는 문서 세트에 이러한 환영 페이지 변경 사항을 적용하려면이 콘텐츠 유형 에서 상속받은 문서 세트의 시작 페이지를 upting 옆에있는 확인란을 선택하십시오. .

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top