分类: Windows平台
2022-10-23 17:10:58
获取计算机名:
Text1.text = VBA.Environ("computername")
获取用户名:
text1.text=VBA.Environ("username")
获取计算机IP地址 :
Dim strLocalIP As String
Dim winIP As Object
Set winIP = CreateObject("MSWinsock.Winsock")
strLocalIP = winIP.localip
API 获取计算机名:
Private Declare Function GetComputerName Lib "kernel32" _
Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Sub Form_Click()
Dim StrT As String * 255
GetComputerName StrT, 255
Print StrT
End Sub
API获取用户名:
Private Declare Function GetUserName Lib "advapi32.dll" _
Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Sub Form_Click()
Dim StrT As String * 255
GetUserName StrT, 255
Print StrT
End Sub