' Collection of code snippets by Arne Vajhøj 
' (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
Declare Sub NetServerGetInfo Lib "Netapi32" (ByVal servername As String, ByVal level As Integer, ByRef bufptr As Long)
Declare Sub NetApiBufferFree Lib "Netapi32" (ByVal bufptr As Long)
Declare Sub CopyMemoryRead Lib "kernel32" Alias "RtlMoveMemory" (dest As Any, ByVal src As Long, ByVal nobyt As Long)

Type SERVER_INFO_101
    sv101_platform_id  As Long
    sv101_name As Long
    sv101_version_major As Long
    sv101_version_minor As Long
    sv101_type As Long
    sv101_comment As Long
End Type

Function GetServerVersion(node As String) As String
    Dim buf As SERVER_INFO_101
    Dim bufptr As Long
    Call NetServerGetInfo(StrConv(node, vbUnicode), 101, bufptr)
    Call CopyMemoryRead(buf, bufptr, 24)
    Call NetApiBufferFree(bufptr)
    GetServerVersion = buf.sv101_version_major & "." & buf.sv101_version_minor
End Function

Function test()
    MsgBox GetServerVersion("\\ARNEPC2")
    MsgBox GetServerVersion("\\ARNE")
End Function
