Jump to content


Photo

İstemci makinanın fiziksel adresi (mac address) nasıl alınır


  • Please log in to reply
5 replies to this topic

#1 muttalip65

muttalip65

    Member

  • uniGUI Subscriber
  • PipPip
  • 11 posts

Posted 19 October 2017 - 10:57 AM

Uygulamamda istemci makinanın fiziksel adresini almak istiyorum. İstemci makinanın IP adresini alabiliyoruz.

Bizim için gerekli olan sunucuya bağlanan bilgisayarların fiziksel adreslerini alabilmek. Bu konuda yardımlarınızı bekliyorum.

 

Şimdeden teşekkürler.

 

 


  • 0

#2 mohammad

mohammad

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 676 posts
  • LocationKufur Kassem, Palestine

Posted 19 October 2017 - 11:00 AM

Imkansız. Güvenlik konuları    (google translate)


  • 0

#3 pedrisco

pedrisco

    Member

  • Members
  • PipPip
  • 13 posts

Posted 19 October 2017 - 11:59 AM

Cause security reasons you can't make it through the browser unless you use browser specific features, but in a local network you can use the next function, you can use hostname or ip address, i've tested with ipv4 and it works (xe3).

 

function GetMacAddress(const AServerName : string) : string;
 type
      TNetTransportEnum = function(pszServer : PWideChar;
                                   Level : DWORD;
                                   var pbBuffer : pointer;
                                   PrefMaxLen : LongInt;
                                   var EntriesRead : DWORD;
                                   var TotalEntries : DWORD;
                                   var ResumeHandle : DWORD) : DWORD; stdcall;

     TNetApiBufferFree = function(Buffer : pointer) : DWORD; stdcall;

     PTransportInfo = ^TTransportInfo;
      TTransportInfo = record
                        quality_of_service : DWORD;
                        number_of_vcs : DWORD;
                        transport_name : PWChar;
                        transport_address : PWChar;
                        wan_ish : boolean;
                      end;

var E,ResumeHandle,
     EntriesRead,
     TotalEntries : DWORD;
     FLibHandle : THandle;
     sMachineName,
     sMacAddr,
     Retvar : string;
     pBuffer : pointer;
     pInfo : PTransportInfo;
     FNetTransportEnum : TNetTransportEnum;
     FNetApiBufferFree : TNetApiBufferFree;
     pszServer : array[0..128] of WideChar;
     i,ii,iIdx : integer;
 begin
   sMachineName := trim(AServerName);
   Retvar := '00-00-00-00-00-00';

  // Add leading \\ if missing
   if (sMachineName <> '') and (length(sMachineName) = 2) then begin
     if copy(sMachineName,1,2) <> '\\' then
       sMachineName := '\\' + sMachineName
   end;

  // Setup and load from DLL
   pBuffer := nil;
   ResumeHandle := 0;
   FLibHandle := LoadLibrary('NETAPI32.DLL');

  // Execute the external function
   if FLibHandle <>0 then begin
     @FNetTransportEnum := GetProcAddress(FLibHandle,'NetWkstaTransportEnum');
     @FNetApiBufferFree := GetProcAddress(FLibHandle,'NetApiBufferFree');
     E := FNetTransportEnum(StringToWideChar(sMachineName,pszServer,129),0,
                            pBuffer,-1,EntriesRead,TotalEntries,Resumehandle);

    if E = 0 then begin
       pInfo := pBuffer;

      // Enumerate all protocols - look for TCPIP
       for i := 1 to EntriesRead do begin
         if pos('TCPIP',UpperCase(pInfo^.transport_name)) <>0 then begin
           // Got It - now format result 'xx-xx-xx-xx-xx-xx'
           iIdx := 1;
           sMacAddr := pInfo^.transport_address;

          for ii := 1 to 12 do begin
             Retvar[iIdx] := sMacAddr[ii];
             inc(iIdx);
             if iIdx in [3,6,9,12,15] then inc(iIdx);
           end;
         end;

        inc(pInfo);
       end;
       if pBuffer  <>nil then FNetApiBufferFree(pBuffer);
     end;

    try
       FreeLibrary(FLibHandle);
     except
       // Silent Error
     end;
   end;

  Result := Retvar;
 end;

 

source:https://www.experts-...w-Its-Name.html

 

Hope it helps.


  • 0

#4 mohammad

mohammad

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 676 posts
  • LocationKufur Kassem, Palestine

Posted 19 October 2017 - 06:30 PM

The server knows ONLY the public IP address of client, this how NAT works.
  • 0

#5 multimesut

multimesut

    Active Member

  • uniGUI Subscriber
  • PipPipPip
  • 73 posts

Posted 20 October 2017 - 08:44 AM

Evet client ile server aynı networkde değil ise NAT protokolünden dolayı her zaman client lerin bağlı olduğu modemin MAC adresini alabilirsin. Modemin arkasında duran client lerin MAC larını alamazsın. (WEB Sayfası tarafından)


  • 0

#6 ismailt35

ismailt35

    Newbie

  • Members
  • Pip
  • 1 posts

Posted 05 November 2017 - 02:14 PM

hello. I'm trying a prgogram. a device is connected to the computer via ethernet. I want get TCP port informations this device

have a example?. 


  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users