[英]How to get the name of current application in C#
我想获得它在Windows上运行的当前应用程序的名称。
例如,如果我使用ie,此功能提供“Internet Explorer”或者如果我使用Google Chrome,请给Chrome ...
System.AppDomain.CurrentDomain.FriendlyName
或者可能
System.Reflection.Assembly.GetExecutingAssembly()
或者如果你的意思是你想要活动窗口的名称那么你应该看看;
试试这个,如果你使用过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;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.