gpt4 book ai didi

c# - GetForegroundWindow 抛出 Win32Exception 拒绝访问

转载 作者:太空宇宙 更新时间:2023-11-03 13:52:04 26 4
gpt4 key购买 nike

public partial class Form1 : Form
{
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
private static extern IntPtr GetForegroundWindow();

public Form1()
{
InitializeComponent();
var proc = Process.GetProcesses().Single(x => x.Handle == GetForegroundWindow());
}
}

我试过以管理员身份运行该应用程序,但不行。我在这里做错了什么,我得到这个异常?

最佳答案

事实证明,我正在做的整个循环也在遍历 protected 进程,这导致访问被拒绝

关于c# - GetForegroundWindow 抛出 Win32Exception 拒绝访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13430734/

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