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