如何获取活动窗口的类名?
通过使用此代码,我可以获得活动窗口的标题..
[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;
但是我该如何获取活动窗口的类名呢?
只需要调用GetClassName()即可。 这将返回窗口的Windows类名,它与C#类没有任何关系。 无法在另一个进程中获取窗口的C#类名。 如果这是一个Winforms应用程序,请查看Managed Spy ++工具以获取可能的黑客攻击。
- 如何使用.NET在FoxPro备注字段中提取数据?
- 如何在WPF中为TranslateTransform和ScaleTransform设置动画
- 通过c#控制VLC
- MVVM – 如何在行中的按钮上的MouseOver上显示DataGrid中的弹出窗口
- AutoFoture与AutoMoq和具体对象注入
- HttpClient和ReadAsAsync ()扩展方法
- 如何写入stdin /从SSH连接的远程进程的stdout读取? (Renci.SshNet)
- 重写url。 asp.net c#
- 在发现’EntityFrameworkConfiguration’类型之前使用了默认的DbConfiguration实例