Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
10年积累的网站设计、成都网站设计经验,可以快速应对客户对网站的新想法和需求。提供各种问题对应的解决方案。让选择我们的客户得到更好、更有力的网络服务。我虽然不认识你,你也不认识我。但先网站设计后付款的网站建设流程,更有新北免费网站建设让你可以放心的选择与我们合作。
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'计算机名称
s = String(128, Chr(0))
GetUserName s, Len(s)
s = UCase(Left(s, InStr(1, s, Chr(0)) - 1))
sMC = s‘当前用户名称
End Sub
'用这种方法在远程获得再发回本机就可以吧
'取计算机型号暂时不会
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim UserID As String = Environment.GetEnvironmentVariable("USERNAME") '获取用户名
MsgBox(UserID)
End Sub
用Environment类中的GetEnvironmentVariable方法。
保存用户名的环境变量是USERNAME。
比如
string username=Environment.GetEnvironmentVariable("USERNAME")
建立一个模块,在其中定义全局变量
Public a as string
public b as string
然后在注册,登陆界面分别引用就好了