1.獲取當(dāng)前電腦名:System.Net.Dns.GetHostName()
創(chuàng)新互聯(lián)主營(yíng)安化網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營(yíng)網(wǎng)站建設(shè)方案,手機(jī)APP定制開(kāi)發(fā),安化h5微信小程序搭建,安化網(wǎng)站營(yíng)銷推廣歡迎安化等地區(qū)企業(yè)咨詢
2.根據(jù)電腦名取出全部IP地址:System.Net.Dns.Resolve(電腦名).AddressList
或者 System.Net.Dns.GetHostByName(電腦名).AddressList
3.根據(jù)IP地址取出電腦名:System.Net.Dns.Resolve(IP地址).HostName
Dim?strHostName?As?String????????strHostName?=?Dns.GetHostName()????????Dim?ipEntry?As?IPHostEntry????????ipEntry?=?Dns.GetHostEntry(strHostName)????????Dim?ip?As?String????????ip?=?ipEntry.AddressList(0).ToString()
Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Sub GetName()
Dim sJM As String
Dim sMC As String
Dim sIP As String
Dim s As String
s = String(128, Chr(0))
GetComputerName s, Len(s)
s = UCase(Left(s, InStr(1, s, Chr(0)) - 1))
sJM = s'計(jì)算機(jī)名稱
s = String(128, Chr(0))
GetUserName s, Len(s)
s = UCase(Left(s, InStr(1, s, Chr(0)) - 1))
sMC = s‘當(dāng)前用戶名稱
End Sub
'用這種方法在遠(yuǎn)程獲得再發(fā)回本機(jī)就可以吧
'取計(jì)算機(jī)型號(hào)暫時(shí)不會(huì)
Dim IPAdress As System.Net.IPAddress
HostName = System.Net.Dns.GetHostName '獲得本機(jī)的機(jī)器名
IPAdress = System.Net.Dns.GetHostByName(HostName).AddressList.GetValue(0) '獲得本機(jī)的IP
Me.TextBox1.Text = HostName '本機(jī)機(jī)器名
Me.TextBox2.Text = IPAdress.ToString '本機(jī)的IP
本文名稱:vb.net獲取主機(jī)名的簡(jiǎn)單介紹
URL分享:http://vcdvsql.cn/article34/hecgse.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供服務(wù)器托管、關(guān)鍵詞優(yōu)化、網(wǎng)站維護(hù)、商城網(wǎng)站、微信小程序、搜索引擎優(yōu)化
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)