Function ComputerNumber() As String
'Returns the computername
Dim lngLen As Long, lngX As Long, strCompName As String
lngLen = 16
strCompName = String$(lngLen, 0)
lngX = apiGetComputerName(strCompName, lngLen)
If lngX <> 0 Then
ComputerNumber = Left$(strCompName, lngLen)
Else
ComputerNumber = ""
End If
End Function
sparx said:It gives me a typemismatch error when it calls the 'WGetComputer' function
Public Declare Function WGetComputer Lib "kernel32" Alias _
"GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Mile-O-Phile said:
You need to have the API Declaration.
Code:Public Declare Function WGetComputer Lib "kernel32" Alias _ "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
ghudson said:What about the simple Environ funciton?
Brilliantghudson said:What about the simple Environ funciton?