2
通过使用此代码,我可以得到活动窗口的标题..如何获取活动窗口的类名?
[DllImport("user32.dll")]
static extern IntPtr GetForegroundWindow();
[DllImport("user32.dll")]
static extern int GetWindowText(IntPtr hWnd, StringBuilder text, int count);
private string GetActiveWindowTitle()
{
const int nChars = 256;
IntPtr handle = IntPtr.Zero;
StringBuilder Buff = new StringBuilder(nChars);
handle = GetForegroundWindow();
if (GetWindowText(handle, Buff, nChars) > 0)
{
return Buff.ToString();
}
return null;
但我应该怎么做才能获得活动窗口的类名?
User32的[GetClassNameA](http://www.pinvoke.net/default.aspx/user32.getclassname)调用? - *另请参阅[This support.microsoft Doc](http://support.microsoft.com/kb/112649)* – 2011-03-29 17:06:01
您是指以Win32术语表示的窗口类,还是您的意思是C#类的名称在窗户后面? – dthorpe 2011-03-29 17:22:34