我想获取它在Windows上运行的当前应用程序的名称。如何在C#中获取当前应用程序的名称
例如,如果我用IE浏览器,这个功能给的 “Internet Explorer”,或者如果我用谷歌Chrome浏览器,Chrome浏览器给...
我想获取它在Windows上运行的当前应用程序的名称。如何在C#中获取当前应用程序的名称
例如,如果我用IE浏览器,这个功能给的 “Internet Explorer”,或者如果我用谷歌Chrome浏览器,Chrome浏览器给...
System.AppDomain.CurrentDomain.FriendlyName
也许
System.Reflection.Assembly.GetExecutingAssembly()
或者如果你的意思是你想要活动窗口的名字,那么你应该看看;
How do I get the title of the current active window using c#?
试试这个,如果你已经使用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;
}
}
Ops,这给出了他的名字。这对我没有用。 –
你的意思是你想要当前活动窗口的名称?如果是这样,请参阅 http://stackoverflow.com/questions/115868/how-do-i-get-the-title-of-the-current-active-window-using-c – madbrendon