十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
建立一个模块,在其中定义全局变量
创新互联公司主营岳西网站建设的网络公司,主营网站建设方案,重庆APP开发,岳西h5微信小程序开发搭建,岳西网站营销推广欢迎岳西等地区企业咨询
Public a as string
public b as string
然后在注册,登陆界面分别引用就好了
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")
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'计算机名称
s = String(128, Chr(0))
GetUserName s, Len(s)
s = UCase(Left(s, InStr(1, s, Chr(0)) - 1))
sMC = s‘当前用户名称
End Sub
'用这种方法在远程获得再发回本机就可以吧
'取计算机型号暂时不会