Recent

Author Topic: MAC Address  (Read 31173 times)

ASerge

  • Hero Member
  • *****
  • Posts: 2242
Re: MAC Address
« Reply #15 on: October 31, 2017, 02:53:18 am »
In Windows, all information is contained in the registry. You can read it directly:
Code: Pascal  [Select][+][-]
  1. uses LazUTF8, Registry;
  2.  
  3. type
  4.   TOpenRegistry = class(TRegistry);
  5.  
  6. function ReadMultiSZ(R: TRegistry; const ValueName: string): string;
  7. var
  8.   Size: Integer;
  9.   Unused: TRegDataType;
  10.   OpenRegistry: TOpenRegistry absolute R;
  11. begin
  12.   Size := R.GetDataSize(ValueName);
  13.   SetLength(Result, Size);
  14.   if Size > 0 then
  15.   begin
  16.     OpenRegistry.GetData(ValueName, @Result[1], Size, Unused);
  17.     StringReplace(Result, #0, ', ', [rfReplaceAll]);
  18.   end;
  19. end;
  20.  
  21. procedure TForm1.FormCreate(Sender: TObject);
  22. const
  23.   CNetworkCards = '\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards\';
  24.   CNetworks = '\SYSTEM\CurrentControlSet\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}\';
  25.   CInterfaces = '\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\';
  26.   CDNSServers: array [Boolean] of string = ('NameServer', 'DhcpNameServer');
  27.   CIPAddress: array [Boolean] of string = ('IPAddress', 'DhcpIPAddress');
  28.   CGateway: array [Boolean] of string = ('DefaultGateway', 'DhcpDefaultGateway');
  29.   CSubnetMask: array [Boolean] of string = ('SubnetMask', 'DhcpSubnetMask');
  30. var
  31.   R: TRegistry;
  32.   KeyNames: TStringList;
  33.   InstanceId, ConnectionName, DNSServers: string;
  34.   ListItem: TListItem;
  35.   IsDHCP: Boolean;
  36.   i: Integer;
  37. begin
  38.   with ListView1.Columns do
  39.   begin
  40.     Add.Caption := 'ConnectionName';
  41.     Add.Caption := 'DHCPServer';
  42.     Add.Caption := 'DNSServers';
  43.     Add.Caption := 'IPAddress';
  44.     Add.Caption := 'Gateway';
  45.     Add.Caption := 'SubnetMask';
  46.   end;
  47.   for i := 0 to ListView1.ColumnCount - 1 do
  48.     ListView1.Columns[i].AutoSize := True;
  49.   ListView1.ViewStyle := vsReport;
  50.   R := TRegistry.Create;
  51.   try
  52.     R.RootKey := HKEY_LOCAL_MACHINE;
  53.     if not R.OpenKeyReadOnly(CNetworkCards) then
  54.       Exit;
  55.     KeyNames := TStringList.Create;
  56.     try
  57.       R.GetKeyNames(KeyNames);
  58.       for i := 0 to KeyNames.Count - 1 do
  59.         if R.OpenKeyReadOnly(CNetworkCards + KeyNames[i]) then
  60.         begin
  61.           InstanceId := R.ReadString('ServiceName');
  62.           if InstanceId = '' then
  63.             Continue;
  64.           if not R.OpenKeyReadOnly(CNetworks + InstanceId + '\Connection') then
  65.             Continue;
  66.           ConnectionName := WinCPToUTF8(R.ReadString('Name'));
  67.           if not R.OpenKeyReadOnly(CInterfaces + InstanceId) then
  68.             Continue;
  69.           ListItem := ListView1.Items.Add;
  70.           ListItem.Caption := ConnectionName;
  71.           IsDHCP := R.ReadBool('EnableDHCP');
  72.           if IsDHCP then
  73.             ListItem.SubItems.Append(R.ReadString('DhcpServer'))
  74.           else
  75.             ListItem.SubItems.Append('');
  76.           DNSServers := R.ReadString(CDNSServers[IsDHCP]);
  77.           ListItem.SubItems.Append(StringReplace(DNSServers, ' ', ', ', [rfReplaceAll]));
  78.           ListItem.SubItems.Append(ReadMultiSZ(R, CIPAddress[IsDHCP]));
  79.           ListItem.SubItems.Append(ReadMultiSZ(R, CGateway[IsDHCP]));
  80.           ListItem.SubItems.Append(ReadMultiSZ(R, CSubnetMask[IsDHCP]));
  81.         end;
  82.     finally
  83.       KeyNames.Free;
  84.     end;
  85.   finally
  86.     R.Free;
  87.   end;
  88. end;

Ericktux

  • Sr. Member
  • ****
  • Posts: 345
Re: MAC Address
« Reply #16 on: October 31, 2017, 06:37:43 am »
Greetings friends, I share a project to obtain the mac ip and external ip.   :) :)

Code: Pascal  [Select][+][-]
  1. unit main;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   windows, Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
  9.   Buttons, Menus, jwatlhelp32, shlobj, mi_about, registry, JwaIpHlpApi, JwaIpTypes,
  10.   synaip, httpsend, synautil;
  11.  
  12. const
  13.   nString = 'SOFTWARE\MICROSOFT\WINDOWS NT\CURRENTVERSION\NetworkCards';
  14.   //nString = '\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards\';
  15.  
  16.  
  17.   nEthernet = 'Ethernet';
  18.   nEtherjet = 'Etherjet'; {if Hardware IBM PL300 with Chip 10/100}
  19.   {nTcpIp1 = 'SYSTEM\CurrentControlSet\Services\';
  20.   nTcpIp2 = '\Parameters\Tcpip';}
  21.  
  22.   nTcpIp1 = 'SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\';
  23.   //nTcpIp2 = '\Parameters\Tcpip';
  24.  
  25. type
  26.   { TForm_ips }
  27.  
  28.   TForm_ips = class(TForm)
  29.     BitBtn1: TBitBtn;
  30.     BitBtn2: TBitBtn;
  31.     BitBtn3: TBitBtn;
  32.     Button1: TButton;
  33.     Memo1: TMemo;
  34.     MenuItem1: TMenuItem;
  35.     MenuItem2: TMenuItem;
  36.     MenuItem3: TMenuItem;
  37.     PopupMenu1: TPopupMenu;
  38.     procedure BitBtn1Click(Sender: TObject);
  39.     procedure BitBtn2Click(Sender: TObject);
  40.     procedure BitBtn3Click(Sender: TObject);
  41.     procedure Button1Click(Sender: TObject);
  42.     procedure FormCreate(Sender: TObject);
  43.     procedure MenuItem1Click(Sender: TObject);
  44.     procedure MenuItem2Click(Sender: TObject);
  45.     procedure MenuItem3Click(Sender: TObject);
  46.   private
  47.     { private declarations }
  48.   public
  49.     procedure getall_nets;
  50.     function get_adapters_info: TStrings;
  51.     { public declarations }
  52.   end;
  53.  
  54. var
  55.   Form_ips: TForm_ips;
  56.   mydestino: string;
  57.  
  58.   reg: TRegistry;
  59.   buffer1, buffer2, buffer3: array [1..32] of Char;
  60.   i, dhcp_valor: Integer;
  61.   ipaddress, subnetmask, DefaultGateway, dns: string;
  62.   Adapter, Adapter_Key: string;
  63.   datos1, datos2, datos3, datos4: string;
  64.   stringlist: TStrings;
  65.   astring, description, st: string;
  66.   //listaRED: TStringList;
  67.  
  68.   my_puerta_enlace, my_ip, my_mask, my_dns: TStringList;
  69.   Buffer33: PChar;
  70.   BufSize: Integer;    {Bufsize requested but not used
  71.                         Bufsize erforderlich aber nicht benutzt}
  72.   Lista: TstringList;
  73.  
  74. implementation
  75.  
  76. {$R *.lfm}
  77.  
  78.  
  79. { TForm_ips }
  80.  
  81. procedure my_ip_externo;
  82. var
  83.   HTTPGetResult: boolean;
  84.   HTTPSender: THTTPSend;
  85.   URL:String;
  86.   Content : TStringList;
  87.   s:String;
  88. begin
  89.  
  90.     //result:='';
  91.     URL:='http://checkip.dyndns.org';
  92.     HTTPSender:=THTTPSend.Create;
  93.     Content :=TStringList.Create;
  94.     try
  95.  
  96.       HTTPGetResult:=HTTPSender.HTTPMethod('GET', URL);
  97.       if HTTPSender.Resultcode=200 then
  98.       begin
  99.         Content.LoadFromStream(HTTPSender.Document);
  100.         if Content.Count>0 then
  101.         begin
  102.           s:=Content.Strings[0];
  103.           synautil.Fetch(s,'Current IP Address:');
  104.           s:=synautil.Fetch(s,'<');
  105.           s:=trim(s);
  106.           if IsIp(s) then
  107.           //result:=s;
  108.           begin
  109.             //Form_ips.Memo1.Clear;
  110.             Form_ips.Memo1.Lines.Add('DIRECCION IP EXTERNA :');
  111.             Form_ips.Memo1.Lines.Add('-------------------------');
  112.             Form_ips.Memo1.Lines.add(s);
  113.             Form_ips.Memo1.Lines.Add('');
  114.  
  115.           end;
  116.         end;
  117.       end;
  118.     finally
  119.       Content.Free;
  120.       HTTPSender.Free;
  121.     end;
  122. end;
  123.  
  124. function tform_ips.get_adapters_info: TStrings;
  125. const
  126.   WIRELESS_ADAPTER = 71;
  127.   ETHERNET_ADAPTER = 6;
  128.  
  129. var
  130.   NumInterfaces: Cardinal;
  131.   AdapterInfo: array of TIpAdapterInfo;
  132.   OutBufLen: ULONG;
  133.   i: integer;
  134.   mac, Tipo : string;
  135.   AdaptersInfo : TStrings;
  136. begin
  137.   GetNumberOfInterfaces(NumInterfaces);
  138.   SetLength(AdapterInfo, NumInterfaces);
  139.   OutBufLen := NumInterfaces * SizeOf(TIpAdapterInfo);
  140.   GetAdaptersInfo(@AdapterInfo[0], OutBufLen);
  141.  
  142.   AdaptersInfo := TStringList.Create;
  143.  
  144.   for i := 0 to NumInterfaces - 1 do begin
  145.  
  146.     mac := Format('%.2x:%.2x:%.2x:%.2x:%.2x:%.2x',
  147.           [AdapterInfo[i].Address[0], AdapterInfo[i].Address[1],
  148.            AdapterInfo[i].Address[2], AdapterInfo[i].Address[3],
  149.            AdapterInfo[i].Address[4], AdapterInfo[i].Address[5]]);
  150.  
  151.     case AdapterInfo[i].Type_ of
  152.       WIRELESS_ADAPTER : Tipo := 'WIF';
  153.       ETHERNET_ADAPTER : Tipo := 'ETH';
  154.     end;
  155.  
  156.     if AdapterInfo[i].Description <> EmptyStr then
  157.       AdaptersInfo.Add(IntToStr(i)
  158.                + ' - ' + Tipo
  159.                + ' - ' + AdapterInfo[i].Description
  160.                + ' - ' + mac);
  161.   end;
  162.   Result := AdaptersInfo;
  163. end;
  164.  
  165. procedure ReadREG_MULTI_SZ(const CurrentKey: HKey; const Subkey, ValueName: string;
  166.   Strings: TStrings);
  167. var
  168.   valueType: DWORD;
  169.   valueLen: DWORD;
  170.   p, buffer: PChar;
  171.   key: HKEY;
  172. begin
  173.   // Clear TStrings
  174.   // TStrings leeren
  175.   Strings.Clear;
  176.   // open the specified key
  177.   // CurrentKey Schlüssel öffnen
  178.   if RegOpenKeyEx(CurrentKey,
  179.                   PChar(Subkey),
  180.                   0, KEY_READ, key) = ERROR_SUCCESS then
  181.   begin
  182.     // retrieve the type and data for a specified value name
  183.     // Den Typ und Wert des Eintrags Ermitteln.
  184.     SetLastError(RegQueryValueEx(key,
  185.                  PChar(ValueName),
  186.                  nil,
  187.                  @valueType,
  188.                  nil,
  189.                  @valueLen));
  190.     if GetLastError = ERROR_SUCCESS then
  191.       if valueType = REG_MULTI_SZ then
  192.       begin
  193.         GetMem(buffer, valueLen);
  194.         try
  195.           // receive the value's data (in an array).
  196.           // Ein Array von Null-terminierten Strings
  197.           // wird zurückgegeben
  198.           RegQueryValueEx(key,
  199.                           PChar(ValueName),
  200.                           nil,
  201.                           nil,
  202.                           PBYTE(buffer),
  203.                           @valueLen);
  204.           // Add values to stringlist
  205.           // Werte in String Liste einfügen
  206.           p := buffer;
  207.           while p^ <> #0 do
  208.           begin
  209.             Strings.Add(p);
  210.             Inc(p, lstrlen(p) + 1)
  211.           end
  212.         finally
  213.           FreeMem(buffer)
  214.         end
  215.       end
  216.       else
  217.         raise ERegistryException.Create('Stringlist expected/ String Liste erwartet...')
  218.     else
  219.       my_puerta_enlace.Add('No Encontrado');
  220.       {raise ERegistryException.Create('Cannot Read MULTI_SZ Value/'+
  221.         'Kann den MULTI_SZ Wert nicht lesen...');}
  222.   end;
  223. end;
  224.  
  225. procedure tform_ips.getall_nets;
  226. var
  227.  
  228.   nPos: integer;
  229.   ServiceName: string;
  230. begin
  231.    //listaRED := TStringList.Create;
  232.   form_ips.Memo1.Clear;
  233.  
  234.  
  235.   reg := TRegistry.Create;
  236.   stringlist  := TStringList.Create;
  237.   reg.RootKey := HKEY_LOCAL_MACHINE;
  238.   reg.OpenKeyReadOnly(nString);
  239.   reg.GetKeyNames(stringlist);    {search all subkeys
  240.                                    such alle unterschlüssel}
  241.   reg.CloseKey;
  242.  
  243.   Memo1.Lines.Add('ADAPTADORES DE RED :');
  244.   Memo1.Lines.Add('-------------------------');
  245.  
  246.  
  247.   for i := 0 to (stringlist.Count - 1) do
  248.   begin
  249.     st := stringlist[i];
  250.     aString := nString + '\' + st;
  251.     reg := TRegistry.Create;
  252.     reg.RootKey := HKEY_LOCAL_MACHINE;
  253.     reg.OpenKeyReadOnly(aString);
  254.     description := reg.ReadString('Description');
  255.     //listaRED.Add(description);
  256.     //ShowMessage(description); // ok
  257.  
  258.     begin
  259.       ServiceName := reg.ReadString('ServiceName');
  260.       //Adapter_Key := nTcpIp1 + ServiceName + nTcpIp2;   // original
  261.       Adapter_Key := nTcpIp1 + ServiceName;
  262.     end;
  263.  
  264.     adapter := Adapter_Key; // SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{A20B42C2-2312-4B24-9845-EEEDC1EE5F5C}
  265.   if adapter <> '' then
  266.   begin
  267.  
  268.     Reg := TRegistry.Create;
  269.     //try
  270.       Reg.RootKey := HKEY_LOCAL_MACHINE;
  271.       Reg.OpenKeyReadOnly(adapter);
  272.       //Reg.ReadBinaryData('dhcpIpAddress', buffer1, BufSize);
  273.       //datos1:=reg.ReadString('dhcpIpAddress');
  274.       dhcp_valor:=reg.ReadInteger('EnableDHCP');
  275.       //ShowMessage(inttostr(dhcp_valor));
  276.       //description := reg.ReadString('Description');
  277.     //finally
  278.       Reg.CloseKey;
  279.       Reg.Free;
  280.     //end;
  281.  
  282.   if dhcp_valor <> 0 then   // acá determinar si la ip es fija (puesta por el usuario o es dinámica)
  283.   begin
  284.     Reg := TRegistry.Create;
  285.     try
  286.       Reg.RootKey := HKEY_LOCAL_MACHINE;
  287.       Reg.OpenKeyReadOnly(adapter);
  288.       //Reg.ReadBinaryData('dhcpIpAddress', buffer1, BufSize);
  289.       if reg.ValueExists('dhcpIpAddress') then datos1:=reg.ReadString('dhcpIpAddress')
  290.       else datos1:='No Encontrado';
  291.       //description := reg.ReadString('Description');
  292.      finally
  293.       Reg.CloseKey;
  294.       Reg.Free;
  295.     end;
  296.  
  297.     Reg := TRegistry.Create;
  298.     try
  299.       Reg.RootKey := HKEY_LOCAL_MACHINE;
  300.       Reg.OpenKeyReadOnly(adapter);
  301.       //Reg.ReadBinaryData('dhcpSubnetMask', buffer2, BufSize);
  302.       if reg.ValueExists('dhcpSubnetMask') then datos2:=reg.ReadString('dhcpSubnetMask')
  303.       else datos2:='No Encontrado';
  304.     finally
  305.       Reg.CloseKey;
  306.       Reg.Free;
  307.     end;
  308.  
  309.      Reg := TRegistry.Create;
  310.     try
  311.       Reg.RootKey := HKEY_LOCAL_MACHINE;
  312.       Reg.OpenKeyReadOnly(adapter);
  313.       //Reg.ReadBinaryData('dhcpSubnetMask', buffer2, BufSize);
  314.       if reg.ValueExists('DhcpNameServer') then datos3:=reg.ReadString('DhcpNameServer')
  315.       else datos3:='No Encontrado';
  316.     finally
  317.       Reg.CloseKey;
  318.       Reg.Free;
  319.     end;
  320.  
  321.     begin
  322.       my_puerta_enlace := TStringList.Create;
  323.  
  324.       ReadREG_MULTI_SZ(HKEY_LOCAL_MACHINE, adapter, 'DhcpDefaultGateway', my_puerta_enlace);  // puerta enlace  // AQUI PIENSO QUE PODEMOS PONER EN VEZ DE  Memo1.Lines  PONER UNA VARIABLE STRING LUEGO ESA VARIABLE PONERLO EN TAL LUGAR
  325.  
  326.       form_ips.Memo1.Lines.Add('Adaptador de RED  : '+description);
  327.       form_ips.Memo1.Lines.Add('Dirección IP             : '+datos1);  // IP
  328.       form_ips.Memo1.Lines.Add('Máscara de RED      : '+datos2);  // mascara
  329.       form_ips.Memo1.Lines.Add('Puerta de enlace     : '+my_puerta_enlace[0]);  // puerta enlace
  330.       form_ips.Memo1.Lines.Add('DNS                          : '+datos3);  // dns
  331.       form_ips.Memo1.Lines.Add('');
  332.     end;
  333.  
  334.   end
  335.   else
  336.   begin
  337.  
  338.       Reg := TRegistry.Create;
  339.     try
  340.       Reg.RootKey := HKEY_LOCAL_MACHINE;
  341.       Reg.OpenKeyReadOnly(adapter);
  342.       //Reg.ReadBinaryData('dhcpIpAddress', buffer1, BufSize);
  343.       datos3:=reg.ReadString('NameServer');
  344.       //description := reg.ReadString('Description');
  345.     finally
  346.       Reg.CloseKey;
  347.       Reg.Free;
  348.     end;
  349.  
  350.   my_ip:= TStringList.Create;
  351.   my_mask:= TStringList.Create;
  352.   my_puerta_enlace := TStringList.Create;
  353.   ReadREG_MULTI_SZ(HKEY_LOCAL_MACHINE, adapter, 'IpAddress', my_ip);
  354.   ReadREG_MULTI_SZ(HKEY_LOCAL_MACHINE, adapter, 'SubnetMask', my_mask);
  355.   ReadREG_MULTI_SZ(HKEY_LOCAL_MACHINE, adapter, 'DefaultGateway', my_puerta_enlace);
  356.  
  357.   form_ips.Memo1.Lines.Add('Adaptador de RED  : '+description);
  358.   form_ips.Memo1.Lines.Add('Dirección IP             : '+my_ip[0]);  // IP
  359.   form_ips.Memo1.Lines.Add('Máscara de RED      : '+my_mask[0]);  // mascara
  360.   //form_ips.Memo1.Lines.Add('Puerta de enlace     : '+my_puerta_enlace.Text);  // puerta enlace   ORIGINAL
  361.   form_ips.Memo1.Lines.Add('Puerta de enlace     : '+my_puerta_enlace[0]);  // puerta enlace
  362.   form_ips.Memo1.Lines.Add('DNS                          : '+datos3);  // dns
  363.   form_ips.Memo1.Lines.Add('');
  364.  
  365.   end;
  366.   end;
  367.   end;
  368. end;
  369.  
  370. function LeerUsuarioWindows: string;
  371. var
  372.   sNombreUsuario: String;
  373.   dwLongitudNombre: DWord;
  374. begin
  375.   dwLongitudNombre := 255;
  376.   SetLength( sNombreUsuario, dwLongitudNombre );
  377.   if GetUserName( PChar( sNombreUsuario ), dwLongitudNombre ) Then
  378.     Result := Copy( sNombreUsuario, 1, dwLongitudNombre - 1 )
  379.   else
  380.     Result := 'Desconocido';
  381. End;
  382.  
  383.  
  384.  
  385. procedure TForm_ips.Button1Click(Sender: TObject);
  386. begin
  387.   BeginThread(TThreadFunc(@my_ip_externo));
  388. end;
  389.  
  390. procedure TForm_ips.BitBtn1Click(Sender: TObject);
  391. begin
  392.  
  393.   Memo1.clear;
  394.   getall_nets;
  395.   begin
  396.   Memo1.Lines.Add('DIRECCIONES MAC :');
  397.   Memo1.Lines.Add('----------------------');
  398.   Memo1.Lines.Add(get_adapters_info.Text);
  399.   end;
  400.  
  401.   //begin
  402.   BeginThread(TThreadFunc(@my_ip_externo));
  403.   //end;
  404. end;
  405.  
  406. procedure TForm_ips.BitBtn2Click(Sender: TObject);
  407. begin
  408.     with BitBtn2.ClientToScreen(point(0, BitBtn2.Height)) do
  409.     PopupMenu1.Popup(X, Y);
  410.  
  411.     {with SpeedButton9.ClientToScreen(point(0, SpeedButton9.Height)) do
  412.     PopupMenu6.Popup(X, Y);}
  413. end;
  414.  
  415. procedure TForm_ips.BitBtn3Click(Sender: TObject);
  416. begin
  417.  
  418.   Form1_about:= tForm1_about.Create(self);
  419.   Form1_about.ShowModal;
  420. end;
  421.  
  422. procedure TForm_ips.FormCreate(Sender: TObject);
  423. begin
  424.   //obtener_passwifi;
  425.   getall_nets;
  426.   begin
  427.   Memo1.Lines.Add('DIRECCIONES MAC :');
  428.   Memo1.Lines.Add('----------------------');
  429.   Memo1.Lines.Add(get_adapters_info.Text);
  430.   end;
  431.   //begin
  432.   BeginThread(TThreadFunc(@my_ip_externo));
  433.   //end;
  434. end;
  435.  
  436. procedure TForm_ips.MenuItem1Click(Sender: TObject);
  437. var
  438.     I: Integer;
  439.     //SD: TSaveDialog;
  440.     SL: TStringList;
  441.     AppDataPath: Array[0..MaxPathLen] of Char; //Allocate memory
  442. begin
  443.     AppDataPath:='';
  444.     SHGetSpecialFolderPath(0,AppDataPath,CSIDL_DESKTOPDIRECTORY,false);   // obetenemos el path del escritorio
  445.     //Memo1.Lines.Add(AppDataPath);  // ejem:   C:\users\ericksystem\desktop
  446.     Memo1.Lines.SaveToFile(AppDataPath+'\'+LeerUsuarioWindows+'_REPORTE IP y RED.txt');
  447.  
  448. end;
  449.  
  450. procedure TForm_ips.MenuItem2Click(Sender: TObject);
  451. var
  452.   I: Integer;
  453.   SL: TStringList;
  454. begin
  455.  
  456.   Memo1.Lines.SaveToFile(ExtractFilePath(Application.ExeName)+LeerUsuarioWindows+'_REPORTE IP y RED.txt');
  457. end;
  458.  
  459. procedure TForm_ips.MenuItem3Click(Sender: TObject);
  460. var
  461.   I: Integer;
  462.   SD: TSaveDialog;
  463.   {SL: TStringList;}
  464. begin
  465.   SD := TSaveDialog.Create(self);
  466.   try
  467.     with SD do
  468.     begin
  469.       Title := 'Respaldo de Archivo en Formato TXT';
  470.       FileName:=LeerUsuarioWindows+'_REPORTE IP y RED.txt';
  471.       InitialDir := GetCurrentDir;
  472.       Filter := 'Texto (delimitado por tabulaciones) (*.txt)|*.txt';
  473.       DefaultExt := 'txt';
  474.       FilterIndex := 1;
  475.       if Execute then
  476.       begin
  477.         Memo1.Lines.SaveToFile(SD.FileName);
  478.       end;
  479.      end;
  480.   finally
  481.     SD.Free;
  482.   end;
  483. end;
  484.  
  485. end.


I hope it serves you.  :)

heX

  • Newbie
  • Posts: 6
Re: MAC Address
« Reply #17 on: November 09, 2017, 12:54:32 am »
Greetings friends, I share a project to obtain the mac ip and external ip.
This is good but there is not enough code for Linux and iOS.  >:D

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1228
Re: MAC Address
« Reply #18 on: November 09, 2017, 05:58:59 am »
hello,
for Linux and ios  have a look  here or here

Ami calmant, J.P
« Last Edit: November 09, 2017, 06:05:33 am by Jurassic Pork »
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

jraviles

  • Newbie
  • Posts: 6
Re: MAC Address
« Reply #19 on: October 23, 2018, 03:11:39 am »
Greetings friends, I share a project to obtain the mac ip and external ip.   :) :)

Hello Ericktux, I speak of the future (2018) your code brought peace to the galaxy and to the continuous space time, thank you!!!
« Last Edit: October 23, 2018, 03:13:41 am by jraviles »

 

TinyPortal © 2005-2018