我想要获取当前在Windows上运行的应用程序名称。
例如,如果我正在使用IE浏览器,这个函数将返回“Internet Explorer”,如果我正在使用谷歌浏览器,它将返回“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;
}
}