Public Declare Function gethostname Lib "Winsock.dll" (ByVal host_name As String, ByVal namelen As Integer) As Integer'returns your local machines namePublic Function GetLocalHostName() As String
Dim sName$
sName = String(256, 0)
If gethostname(sName, 256) Then
sName = WSA_NoName
Else
If InStr(sName, Chr(0)) Then
sName = Left(sName, InStr(sName, Chr(0)) - 1)
End If
End If
GetLocalHostName = sName
End Function
Dim sName$
sName = String(256, 0)
If gethostname(sName, 256) Then
sName = WSA_NoName
Else
If InStr(sName, Chr(0)) Then
sName = Left(sName, InStr(sName, Chr(0)) - 1)
End If
End If
GetLocalHostName = sName
End Function
我的winnt\system32下面。这是怎么回事?望不吝赐教。
Dim lComputerNameLen As Long
Dim lresult As Long
lComputerNameLen = 256
sComputerName = Space(lComputerNameLen)
lresult = GetComputerName(sComputerName, lComputerNameLen)
sComputerName中就是主机的名字字符串.