在 .Net WinForms 设计时哪里可以找到唯一的会话 ID
我创建了一个自定义剪贴板,因为不可能使我的整个类映射可序列化 - 这是 Windows 剪贴板的要求。
但是,我需要通过唯一的 ID 来区分正在使用我的剪贴板的用户。基本上,我希望能够识别坐在一台 PC 上并打开一份或多份 Visual Studio(或类似版本)的人。
我该怎么做?
ps:这是在设计时。
pps:它应该在 Visual Studio 的副本之间工作并不重要。一份副本就可以了,甚至一张设计图也可以。
I've created a custom clipboard because it's not possible to make my whole class map serializable - which is a requirement for the windows clipboard.
However, I need to distinguish between users who are using my clipboard through a unique id. Basically, I want to be able identify a person who is sat at one PC with one or more copies of visual studio (or similar) open.
How do I do that?
ps: This is at design-time.
pps: It's not critical that it should work between copies of visual studio. One copy would be fine, or even one design surface.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以组合
USERNAME
和SESSIONNAME
环境变量。这将为您提供每个登录会话的唯一 ID。如果有两个人登录控制台,则需要将它们组合起来,而
SESSIONNAME
对于两个用户来说都是“控制台”。为了区分 Visual Studio,您还可以附加 VS 的进程 ID。
如果仅 VS 存在问题,那么进程 ID 本身就足够了,因为两个用户不能共享一个进程。
You can combine the
USERNAME
andSESSIONNAME
environmental variables. This should give you a unique ID per logged on session.You need to combine them in case you have two people logged into the console, whereas the
SESSIONNAME
would be "Console" for both users.In order to distinguish Visual Studios you could append the process id of VS as well.
If only VS is in question, then the process id should be enough in itself, since two users can't share a process.