VB 程序设计

10个成员

取得计算机名

发表于 2016-12-25 4025 次查看
声明:
Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
例子:
Public Function MachineName() As String
Dim sBuffer As String * 255
If GetComputerName(sBuffer, 255&) <> 0 Then
MachineName = Left$(sBuffer, InStr(sBuffer, vbNullChar) - 1
Else
MachineName = "(未知)"
End If
End Function

 

发表回复
你还没有登录,请先登录注册