我怎样才能得到客户端计算机名称 [英] How can i get the Client Computer name

查看:238
本文介绍了我怎样才能得到客户端计算机名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用C#4.0框架Windows窗体。我的程序安装在服务器上的TSE。有迹象表明,连接到该服务器11轻客户端。

I am using C# Framework 4.0 Windows Form. My program is installed on a server TSE. There are 11 light clients that connect to this server.

当其中一个客户机启动我的编程',我怎么能得到他的电脑叫什么名字?

When one of these clients launches my progam, how can I get his PC name ?

推荐答案

假设你正在使用终端服务和远程桌面,您可以检查CLIENTNAME环境变量来检索客户端计算机的名称,但也有一些人报告与它的问题。

Assuming you are using Terminal Services and Remote Desktop, you can check the CLIENTNAME environment variable to retrieve the client machine's name, although some people report problems with it.

您可以得到的 Environment.GetEnvironmentVariable ,如:

var clientName=Environment.GetEnvironmentVariable("CLIENTNAME");



对于基于API的方法,检查的首选方式获取客户端的名字从终端服务器会话它展示了如何使用WMI或终端服务的API检索客户端名称

For an API based method, check Preferred way Of getting Client name From Terminal Server Session which shows how to use WMI or the Terminal Services API to retrieve the client name

更新

嗯,看来的决明子库封装TS API。你可以用获取客户端名称TerminalServicesManager()CurrentSession.ClientName

Hmm, seems the Cassia library encapsulates the TS API. You can get the client name with TerminalServicesManager().CurrentSession.ClientName

另外的SO线程演示如何检索当前会话的客户端名称或所有会话的客户端名称。

Another SO thread shows how to retrieve the current session's client name or the client names of all sessions.

这篇关于我怎样才能得到客户端计算机名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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