|
|
Get Computer NameQuestionIs there a function to get a users computer name ? Answer
Declare Function api32_GetComputerName Lib "kernel32" Alias "GetComputerNameA" _
(ByVal lpBuffer As String, nSize As Long) As Long
Public Function smsGetComputerName() As String
On Error Resume Next
Dim strComputerName As String * 512
Dim lngBufLen As Long
Dim lngRet As Long
lngBufLen = 503
strComputerName = String(512, 0)
lngRet = api32_GetComputerName(strComputerName, lngBufLen)
If lngRet <> 0 Then
smsGetComputerName = Left(strComputerName, lngBufLen)
Else
smsGetComputerName = ""
End If
End Function
HTH, Copyright © 1999-2008 by Shamil Salakhetdinov. Original version is published here All rights reserved. |