Определение имени компьютера в сети (API)
Взято из программы Rules98 - Автор: Грибанов Сергей Юрьевич
Private Declare Function GetComputerNameA Lib "kernel32" (ByVal lpBuffer As String, ByRef nSize As Long) As Long
Private Function GetComputerName() As String
Const MAX_COMUTERNAME = 99
Dim lpBuffer As String * MAX_COMUTERNAME
Dim lenString As Long
lenString = MAX_COMUTERNAME
Call GetComputerNameA(lpBuffer, lenString)
GetComputerName = Left$(lpBuffer, lenString)
End Function
Ещё вариант
Public Function ComputerName() As String
Dim WshNetwork As Object
Set WshNetwork = CreateObject("WScript.Network")
ComputerName = WshNetwork.ComputerName
Set WshNetwork = Nothing
End Function
|