WIN7 键盘挂钩在另一个用户帐户中停止工作?
我使用 C# 创建了自己的家长控制应用程序来监控我的孩子的活动。它以任务栏图标的唯一 GUI 默默地在后台记录所有键盘输入和屏幕。到目前为止,我只是让它在我的管理员帐户中运行,每个人都共享同一个帐户,并且工作正常。问题是,随着孩子的成长,他们找到了一种方法来从任务管理器中杀死它。因此,我需要使用更复杂的方法来保护我的应用程序。我认为我可以通过为每个孩子创建一个单独的标准帐户来轻松解决这个问题,并且我可以将我的应用程序设置为以管理员身份运行以监控他们的所有活动。然而,我遇到了很多问题。
一旦我切换到不同的用户帐户,键盘挂钩似乎就停止工作。这是真的吗?我认为它是全局挂钩 - 它只是用户帐户内的全局挂钩吗?
屏幕捕获也不适用于其他用户帐户。这是我的代码,
它在 g.CopyFromScreen 处失败,并出现错误“句柄无效”:
RECT rc = Win32.GetWindowRect();
using (System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(rc.Width, rc.Height))
{
using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bitmap))
{
g.CopyFromScreen(rc.Location, System.Drawing.Point.Empty, new System.Drawing.Size(rc.Width, rc.Height));
string fileName = Settings.Instance.GetImageFileName();
bitmap.Save(fileName, System.Drawing.Imaging.ImageFormat.Png);
}
}
非常感谢您的帮助。
I created my own parental control app using C# to monitor my kids activity. It logs all the keyboard input and screens in the background silently, with the only gui of taskbar icon. So far, I just let it run in my admin account and everybody share the same account and it works fine. The problem is that as kids grow up, they found a way to kill it from the task manager. So, I need to use a more sophisticated way to protect my app. I thought I could solve this problem easily by creating a separate standard account for each kid and I can setup my app to run as an admin to monitor all their activities. However, I faced a lot of issues.
The keyboard hooks seem to stop working once I switched to a different user account. Is it true? I thought it's global hook - is it just global within the user account?
The screen capturing doesn't work on another user account either. This is my code and
it failed at g.CopyFromScreen with error "the handle is invalid":
RECT rc = Win32.GetWindowRect();
using (System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(rc.Width, rc.Height))
{
using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bitmap))
{
g.CopyFromScreen(rc.Location, System.Drawing.Point.Empty, new System.Drawing.Size(rc.Width, rc.Height));
string fileName = Settings.Instance.GetImageFileName();
bitmap.Save(fileName, System.Drawing.Imaging.ImageFormat.Png);
}
}
Your help is much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只要孩子不是管理员,您就可以在他们的帐户下运行该程序并拒绝对该进程的访问。
例如(已测试):
As long as the kids aren't administrators, you can run the program under their accounts and deny access to the process.
For example (tested):