Wednesday, April 29, 2009

Get Computer Name

'Get Computer Name



Private Const MAX_LENGTH As
Long
= 31

Private Declare Function GetComputerName
Lib "kernel32" Alias
_

"GetComputerNameA" (ByVal lpBuffer
As String, nSize As Long)
As Long



Private Sub Form_Load()

Dim dwLen As Long

Dim strString As String

'Create a buffer

dwLen = MAX_LENGTH + 1

strString = String(dwLen, "X")

'Get the computer name

GetComputerName strString, dwLen

'Get only the actual data

strString = Left(strString, dwLen)

'Show the computer name in message box

MsgBox strString

End Sub

 

No comments:

Post a Comment