1

Konu: Başka Bir Pcnin Mac Adresini almak

Öncelikle Herkese Merhabalar;
Benim Sorum İstediğim Kendi Ağımda olan bir pcnin mac adresini aldırabilir miyim ?
Sorumu Cevaplayanlara Şimdiden teşekkürler

2 Son düzenleyen, rahmi (07.03.2010 23:03:53)

Re: Başka Bir Pcnin Mac Adresini almak

bu banada lazım
vb kodunu buldum vb bilen biri  fox a uyarlarsa  super olur

*****
'Projeye eklenmesi gerekenler:
' 2 adet textbox ve 1 adet buton

Option Explicit

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)
   


Private Sub Form_Load()

   Text1.Text = "192.168.1.101"
   Text2.Text = ""
   Command1.Caption = "Get Remote Mac Address"
   
End Sub


Private Sub Command1_Click()

   Dim sRemoteMacAddress As String
   
   If Len(Text1.Text) > 0 Then
   
      If GetRemoteMACAddress(Text1.Text, sRemoteMacAddress) Then
         Text2.Text = sRemoteMacAddress
      Else
         Text2.Text = "(SendARP call failed)"
      End If
     
   End If

End Sub


Private Function 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

3

Re: Başka Bir Pcnin Mac Adresini almak

bu konular daha önceki formlarda işlendi ama ben genede  altta vereyim kolaylık olsun


? IpToMacAddress("192.168.2.23")


FUNCTION IpToMacAddress(lcIP)
        DECLARE INTEGER inet_addr IN ws2_32.dll STRING cIP
        DECLARE INTEGER SendARP IN iphlpapi.dll;
                INTEGER destIP, INTEGER sourceIP,;
                STRING @ pMacAddr, INTEGER @ PhyAddrLen
        LOCAL lnHr, lnIpAddr, lcMacAddr, lnLen
        lnIpAddr = inet_addr(lcIp)
        lcMacAddr = REPLICATE(CHR(0),6)
        lnLen = 6
        lnHr = SendARP(lnIpAddr,0,@lcMacAddr,@lnLen)
        RETURN BinaryToMac(lcMacAddr,lnLen)
ENDFUNC

FUNCTION BinaryToMac(lcMacAddr, lnLen)
        LOCAL lcMac, xj
        lcMac = ""
        FOR xj = 1 TO lnLen - 1
                lcMac = lcMac + RIGHT(TRANSFORM(ASC(;
                        SUBSTR(lcMacAddr,xj,1)),"@0"),2) + ":"
        ENDFOR
        lcMac = lcMac + RIGHT(TRANSFORM(ASC(;
                SUBSTR(lcMacAddr,lnLen,1)),"@0"),2)
        RETURN lcMac
ENDFUNC

Bilgi Paylaşıldıkça Artar...!

4

Re: Başka Bir Pcnin Mac Adresini almak

Öncelikle Aradım Ama Ben bulamamış olabilrim bunun için özür dilerim bir dahaki sefere forumda daha iyi ararım
Yardımınız için çok teşekkür ederim.

5

Re: Başka Bir Pcnin Mac Adresini almak

Birnefes yazdı:

Öncelikle Aradım Ama Ben bulamamış olabilrim bunun için özür dilerim bir dahaki sefere forumda daha iyi ararım
Yardımınız için çok teşekkür ederim.

Birnefes ;

Özür Dilenecek bir durum yok hepimiz bazen bulamaya biliyoruz . Ayrıca  yardımcı olmaktan mutluluk duyarım

Bilgi Paylaşıldıkça Artar...!