Declare Function GetComputerName Lib "Kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long

 

Sub GetComputerName_test()

Dim Name As String, Length As Long

Length = 255

Name = String(Length, 0)

GetComputerName Name, Length

Name = Left(Name, Length)

MsgBox "此电脑的名称:=" & Name, , "GetComputerName"

End Sub

 

Sub Main()

GetComputerName_test

End Sub