gpt4 book ai didi

c# - 当使用任务管理器暂停特定应用程序进程时如何捕获事件?

转载 作者:太空宇宙 更新时间:2023-11-03 16:53:18 25 4
gpt4 key购买 nike

我正在开发一个简单的应用程序,其中我们为系统上的每个用户预定义了使用配额。如果配额已满..系统应该注销用户帐户..如果允许应用程序运行,就会发生这种情况。但是如果用户自己关闭应用程序..应用程序应该自动注销帐户..

我在表单关闭事件中编写强制注销代码时正是这样做的。但是如果我们使用任务管理器关闭应用程序/进程..未调用表单关闭事件。因此,即使他的时间配额用完了,用户也可以继续..谁能帮我解决这个问题..

最佳答案

这是个好问题。也许您可以制作一个应用程序来查看任务管理器和用户状态。我不确定这对你有帮助,但我会写信

Process[] myApp = Process.GetProcesses("My Application");

if (myApp.Length == 0)
{
// App closed, and check the user status
// If user is still up, make it logoff,
// Also you can track processes with ProcessId too GetProcessesById(5415)
}
else
{
// App is running, there is no problem
}

关于c# - 当使用任务管理器暂停特定应用程序进程时如何捕获事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3164397/

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