且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何创建一个应用程序来跟踪使用PC的用户

更新时间:2022-04-13 06:34:35

1.您需要首先获取当前登录的用户.您可以通过以下方式做到:

WindowsIdentity.GetCurrent().Name

2.您的应用程序与任务管理器密切相关.因此,了解任务管理器是如何工作的.还搜索使用C#或VB创建任务管理器的文章.这将帮助您让您的应用程序知道新的过程已开始.

3.完成此操作后,只需过滤掉当前用户启动的那些内容即可.我不确定这样做的托管方式.尽管advapi32.dll中有一个OpenProcessToken方法可以告诉启动它的用户名.

据我所知,Kernel32.dll也提供了提供许多与过程相关的信息的方法.阅读有关它.您可能会从中得到一些有用的信息.

希望这会有所帮助.
1. You need to get the current logged in user first. That you can do by:

WindowsIdentity.GetCurrent().Name

2. Your application closely relates to task manager. So read about how task manager works. Also search for articles where task manager is created using C# or VB. That will help you letting your application know that a new process was started.

3. Once you are done with this, just filter out those started by current user. I am not sure of managed way of doing this. Although there is a method OpenProcessToken in advapi32.dll that tells the name of user who started it.

From what I know, Kernel32.dll too offers methods that provide a lot of process related information. Read about it. You might get something useful out of it.

Hope this helps.