【问题标题】:How to get the name of current application in C#如何在 C# 中获取当前应用程序的名称
【发布时间】:2013-04-09 15:16:46
【问题描述】:

我想获取它在 Windows 上运行的当前应用程序的名称。

例如,如果我使用,即此功能提供“Internet Explorer”,或者如果我使用 Google chrome,则提供 Chrome...

【问题讨论】:

    标签: c# process


    【解决方案1】:
    System.AppDomain.CurrentDomain.FriendlyName
    

    或许

    System.Reflection.Assembly.GetExecutingAssembly()
    

    或者如果您的意思是想要活动窗口的名称,那么您应该查看;

    How do I get the title of the current active window using c#?

    【讨论】:

    【解决方案2】:

    您可以使用Assembly.FullName

    System.Reflection.Assembly.GetEntryAssembly().FullName;
    

    也请看看这个问题:

    How do I get the name of the current executable in C#?

    【讨论】:

      【解决方案3】:

      试试这个,如果你用过GetWindowThreadProcessId。

      public String GetActiveFileNameTitle()
          {
              IntPtr hWnd = GetForegroundWindow();
              uint procId = 0;
              GetWindowThreadProcessId(hWnd, out procId);
              var proc = Process.GetProcessById((int)procId);
              if (proc != null)
              {
                 return proc.MainModule.FileVersionInfo.ProductName;
              }
      
          }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-11-30
        • 2011-01-06
        • 1970-01-01
        • 1970-01-01
        • 2010-11-24
        • 2013-06-25
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多