Here is cool function to get the name of the computer the user is logged on to on Win95 and WinNT. This is the name of the computer as defined in the Network dialog in Control Panel.
Declare
Public Const MAX_COMPUTERNAME_LENGTH As Long = 15&
Public Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Code
Public Function GetMachineName() As String
Dim plngSize As Long
Dim pstrBuffer As String
pstrBuffer = Space$(MAX_COMPUTERNAME_LENGTH + 1)
plngSize = Len(pstrBuffer)
If GetComputerName(pstrBuffer, plngSize) Then
GetMachineName = Left$(pstrBuffer, plngSize)
End If
End Function
|