Tuesday, October 18, 2011

Get Computer Name in Visual Basic 6

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

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...