gpt4 book ai didi

c# - 如何获取事件窗口的类名?

转载 作者:行者123 更新时间:2023-11-30 15:45:10 24 4
gpt4 key购买 nike

通过使用这段代码,我可以获得事件窗口的标题..

    [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# 类名是不可能的。看看 Managed Spy++ tool如果这是一个 Winforms 应用程序,可能会被黑客攻击。

关于c# - 如何获取事件窗口的类名?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5476190/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com