Get your Server name - the easy way
Get your Server name - the easy way
API Declarations
Private Declare Function lstrlenW Lib "kernel32" _
(ByVal lpString As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32" _
Alias "RtlMoveMemory" (Destination As Any, Source As Any, _
ByVal Length As Long)
Private Declare Function NetGetDCName Lib _
"Netapi32.dll" (strServer As Any, strDomain As Any, _
bufptr As Long) As Long
Private Declare Function NetApiBufferFree Lib _
"Netapi32.dll" (ByVal lpBuffer As Long) As Long
Rate Get your Server name - the easy way
(1(1 Vote))
Private Sub Command1_Click()
Dim l As Long
Dim dc() As Byte
Dim bufptr As Long
l = NetGetDCName(ByVal 0&, _
ByVal 0&, _
bufptr)
MsgBox GetServername(bufptr)
NetApiBufferFree bufptr
End Sub
Private Function GetServername(ByVal l As Long) As String
Dim bbuffer() As Byte
Dim nLen As Long
nLen = lstrlenW(l) * 2
If nLen Then
ReDim bbuffer(0 To (nLen - 1)) As Byte
CopyMemory bbuffer(0), ByVal l, nLen
GetServername = bbuffer
End If
End Function
Get your Server name - the easy way Comments
No comments yet — be the first to post one!
Post a Comment