Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
10年積累的網(wǎng)站設(shè)計(jì)、成都網(wǎng)站設(shè)計(jì)經(jīng)驗(yàn),可以快速應(yīng)對(duì)客戶(hù)對(duì)網(wǎng)站的新想法和需求。提供各種問(wèn)題對(duì)應(yīng)的解決方案。讓選擇我們的客戶(hù)得到更好、更有力的網(wǎng)絡(luò)服務(wù)。我雖然不認(rèn)識(shí)你,你也不認(rèn)識(shí)我。但先網(wǎng)站設(shè)計(jì)后付款的網(wǎng)站建設(shè)流程,更有新北免費(fèi)網(wǎng)站建設(shè)讓你可以放心的選擇與我們合作。
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ī)名稱(chēng)
s = String(128, Chr(0))
GetUserName s, Len(s)
s = UCase(Left(s, InStr(1, s, Chr(0)) - 1))
sMC = s‘當(dāng)前用戶(hù)名稱(chēng)
End Sub
'用這種方法在遠(yuǎn)程獲得再發(fā)回本機(jī)就可以吧
'取計(jì)算機(jī)型號(hào)暫時(shí)不會(huì)
Private?Sub?Button1_Click(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?Button1.Click
Dim?UserID?As?String?=?Environment.GetEnvironmentVariable("USERNAME")?'獲取用戶(hù)名?
MsgBox(UserID)
End?Sub
用Environment類(lèi)中的GetEnvironmentVariable方法。
保存用戶(hù)名的環(huán)境變量是USERNAME。
比如
string username=Environment.GetEnvironmentVariable("USERNAME")
建立一個(gè)模塊,在其中定義全局變量
Public a as string
public b as string
然后在注冊(cè),登陸界面分別引用就好了