2013-04-17 132 views

回答

8
System.AppDomain.CurrentDomain.FriendlyName 

也许

System.Reflection.Assembly.GetExecutingAssembly() 

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

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

+0

Ops,这给出了他的名字。这对我没有用。 –

+1

你的意思是你想要当前活动窗口的名称?如果是这样,请参阅 http://stackoverflow.com/questions/115868/how-do-i-get-the-title-of-the-current-active-window-using-c – madbrendon

0

试试这个,如果你已经使用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; 
     } 

    } 
相关问题