本文介绍了如何在C#中获取远程计算机的IP地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 大家好, 假设有两个系统System1&系统2。 System1 - Windows XP和System2 - Linux。我在System1中安装了WPF应用程序。使用System2的用户将通过与System1的远程连接启动WPF应用程序。 通过WPF应用程序,我可以读取System1的IP地址和Windows登录名通过以下代码。 private 字符串 GetIP() { 字符串 strHostName = ; strHostName = System.Net.Dns.GetHostName(); IPHostEntry ipEntry = System.Net.Dns.GetHostEntry(strHostName); IPAddress [] addr = ipEntry.AddressList; return addr [ 0 ]。ToString(); } String WinUserName_withNetwork = System.Security.Principal.WindowsIdentity.GetCurrent()。Name; 字符串 WinUserNameOnly = System.Environment.UserName; 请帮我看看如何读取System2的IP地址和Windows登录名。解决方案 Hi All,Assume there are two systems System1 & System2. System1 - Windows XP and System2 - Linux. I have installed a WPF application in System1. User who is using the System2 will launch the WPF application thru Remote Connection with System1.Thru WPF application, I can read the IP address and Windows Login Name for the System1 thru the following codes. private String GetIP() { string strHostName = ""; strHostName = System.Net.Dns.GetHostName(); IPHostEntry ipEntry = System.Net.Dns.GetHostEntry(strHostName); IPAddress[] addr = ipEntry.AddressList; return addr[0].ToString(); }String WinUserName_withNetwork = System.Security.Principal.WindowsIdentity.GetCurrent().Name;String WinUserNameOnly = System.Environment.UserName;Please help me how to read the IP address and Windows login name for System2. 解决方案 这篇关于如何在C#中获取远程计算机的IP地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
09-05 15:59