2樓的朋友能否給個源代碼。或者nbtstat的vb源碼。謝謝

解决方案 »

  1.   

    Public Function GetWorkgroupName() As String  '获取工作组名    Dim System As SWbemObjectSet
        Dim item As SWbemObject
        Dim i As Integer    Set System = GetObject("winmgmts:").InstancesOf("Win32_ComputerSystem")
        For Each item In System
            GetWorkgroupName = item.domain
        Next
    End Function
    这是工作组ip用Win32_NetworkAdapterConfiguration类看看
      

  2.   

    连接即可WMI连接远程计算机
    其实最好是用SOCKS但是这方面我也不太清楚
      

  3.   

    答案已找到和大家一起分享
    Private Const NO_ERROR = 0
    Private Declare Function inet_addr Lib "wsock32.dll" (ByVal s As String) As Long
    Private Declare Function SendARP Lib "iphlpapi.dll" (ByVal DestIP As Long, _
                                                         ByVal SrcIP As Long, _
                                                         pMacAddr As Long, _
                                                         PhyAddrLen As Long) As Long
    Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (dst As Any, _
                                                         src As Any, _
                                                         ByVal bcount As Long)
     
    Sub Command1_Click()
        Dim sRemoteMacAddress As String
        If GetRemoteMACAddress("172.16.232.214", sRemoteMacAddress) Then
           MsgBox sRemoteMacAddress
        Else
           MsgBox "(SendARP  call  failed)"
        End If
    End SubFunction GetRemoteMACAddress(ByVal sRemoteIP As String, sRemoteMacAddress As String) As Boolean
      Dim dwRemoteIP  As Long
      Dim pMacAddr    As Long
      Dim bpMacAddr() As Byte
      Dim PhyAddrLen  As Long
      Dim cnt         As Long
      Dim tmp         As String
      'convert the string IP into
      'an unsigned long value containing
      'a suitable binary representation
      'of  the  Internet  address  given
      dwRemoteIP = inet_addr(sRemoteIP)
      If dwRemoteIP <> 0 Then
         'set  PhyAddrLen  to  6
         PhyAddrLen = 6
         'retrieve  the  remote  MAC  address
         If SendARP(dwRemoteIP, 0&, pMacAddr, PhyAddrLen) = NO_ERROR Then
            If pMacAddr <> 0 And PhyAddrLen <> 0 Then
               'returned  value  is  a  long  pointer
               'to  the  mac  address,  so  copy  data
               'to  a  byte  array
               ReDim bpMacAddr(0 To PhyAddrLen - 1)
               CopyMemory bpMacAddr(0), pMacAddr, ByVal PhyAddrLen
               'loop  through  array  to  build  string
               For cnt = 0 To PhyAddrLen - 1
                   If bpMacAddr(cnt) = 0 Then
                      tmp = tmp & "00-"
                   Else
                      tmp = tmp & Hex$(bpMacAddr(cnt)) & "-"
                   End If
               Next
               'remove the trailing dash
               'added above and return True
               If Len(tmp) > 0 Then
                  sRemoteMacAddress = Left$(tmp, Len(tmp) - 1)
                  GetRemoteMACAddress = True
               End If
               Exit Function
            Else
               GetRemoteMACAddress = False
            End If
        Else
           GetRemoteMACAddress = False
        End If     'SendARP
      Else
        GetRemoteMACAddress = False
      End If     'dwRemoteIP
    End Function
      

  4.   

    你这只是获取MAC地址而已。这个很简单主要是工作组。这个可以?