How do I discover how my process was started

后端 未结 4 1251
萌比男神i
萌比男神i 2020-12-21 01:12

We\'ve got a winforms LOB application, which under normal circumstances should be started from a launcher that should do basic version checks and download any updated compon

4条回答
  •  被撕碎了的回忆
    2020-12-21 01:52

    See here: How to get parent process in .NET in managed way

    From the link:

    using System.Diagnostics;
    PerformanceCounter pc = new PerformanceCounter("Process",
    "Creating Process ID", Process.GetCurrentProcess().ProcessName);
    return Process.GetProcessById((int)pc.NextValue());
    

    [Edit: Also see the System.Diagnostics FAQ for some more information about this. Thanks to Justin for the link.]

提交回复
热议问题