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

全部博文(58)

文章存档

2024年(14)

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



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