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

Function Get_CompName() As String
' Returns the name of the local computer.
Dim BUFFER As String * 512, length As Long
length = Len(BUFFER)
If GetComputerName(BUFFER, length) Then
' this API returns non-zero if successful,
' and modifies the length argument
Get_CompName = Left(BUFFER, length)
End If
End Function

Function Get_CompName() As String
' Returns the name of the local computer.
Dim BUFFER As String * 512, length As Long
length = Len(BUFFER)
If GetComputerName(BUFFER, length) Then
' this API returns non-zero if successful,
' and modifies the length argument
Get_CompName = Left(BUFFER, length)
End If
End Function


0 comments:
Post a Comment