该过程在windows是特定的用户? [英] which process in windows is user specific?

查看:76
本文介绍了该过程在windows是特定的用户?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道哪个进程在Windows中是特定的用户,我的意思是得到每个用户登录创建。我试图Explorer.exe的,但是当u开关用户并登录到新帐户,然后将其显示在我的代码旧登录名。基本上,我需要的应用程序时,只需登录该用户的记录。

i wanted to know which process in Windows is user specific, i mean it get created for each user login. i tried explorer.exe but when u switch user and log into new account then it shows old login name in my code. basically i need to just log which user logging when in app.

推荐答案

我想念你,指示创建的Windows服务的标记。这比普通的应用程序非常不同类型的动物,您会收到一个建议不一定转移到另一个。

I missed the tag indicating you created a Windows Service. That's a very different type of animal than a regular application, and the advice you receive for one is not necessarily transferable to the other.

具体来说,我注意到你已经标记这个问题 Windows的7 。如果你想在Windows 7下运行此服务,您需要了解有关如何为Windows服务的模型实质性改变从Windows Vista开始的几件事。具体而言,他们现在在一个孤立的会话运行,并从被禁止直接与用户交互。
也看到的这里一个更好的解释我的答案。

Specifically, I notice that you've tagged this question windows-7. If you're trying to run this service under Windows 7, you need to understand a few things about how the model for Windows Services was substantially altered starting with Windows Vista. Specifically, they now run in an isolated session and are prohibited from interacting directly with the user. Also see my answer here for a better explanation.

根本的一点是,<从Windows服务的角度来看STRONG>,有没有这样的概念作为当前登录的用户即可。 Windows服务运行在自己的孤立会话,不与任何特定用户无关。这就是为什么代码,你发现确定与您期望Windows服务特定进程不工作相关的用户。一个标准的用户不拥有运行该服务的过程。 (和与应用程序更换您的服务也不是一个可行的选择,因为我是怎么理解你的要求。的我解释这里,当一个特定的用户登录,将每当用户注销关闭用户模式应用程序已启动。)

The fundamental point is that, from the perspective of a Windows Service, there is no such concept as the currently logged-on user. A Windows Service runs in its own isolated session and is not affiliated with any particular user. That's why the code you found to determine the user associated with a particular process is not working as you expect for a Windows Service. A standard user doesn't own the process running the service. (And replacing your service with an application is also not a viable option, given how I understand your requirements. As I explain here, user-mode applications are started when a particular user logs on and will be closed whenever that user logs off.)

另一个问题是,一个以上的用户可以登录的同时的单个工作站。 Windows是一个彻底的多用户操作系统,这样就可以期望的最好是枚举的所有的在用户当前登录。该 NetWkstaUserEnum 函数将让你的列表,但请注意,它包括了所有类型的登录,包括交互用户,服务和批处理登录。要调用从C#此功能,您将需要的P / Invoke,您可以找到关于这些信息在上的 pinvoke.net

Another problem is that more than one user can be logged in simultaneously to a single workstation. Windows is a thoroughly multi-user operating system, so the best that you can hope for is to enumerate all of the currently logged in users. The NetWkstaUserEnum function will get you that list, but note that it includes all types of logons, including interactive users, services, and batch logons. To call this function from C#, you will need to P/Invoke—you can find information about that over on pinvoke.net.

这篇关于该过程在windows是特定的用户?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆