Wednesday, April 7, 2010

How to Get Computer Name (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

2 comments:

Cebu City Jobs said...

Thank you, I am now able to get the computer name.

mahasiswa teladan said...

hi..Im student from Informatics engineering, this article is very informative, thanks for sharing :)

Post a Comment

 
Powered by Blogger