Chinaunix首页 | 论坛 | 博客
  • 博客访问: 26110
  • 博文数量: 50
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 455
  • 用 户 组: 普通用户
  • 注册时间: 2011-01-23 14:08
文章分类

全部博文(50)

文章存档

2024年(6)

2023年(22)

2022年(22)

我的朋友

分类: 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



阅读(215) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~