An (albeit not too elegant) solution could be:
uses
Process, StrUtils;
function ExtractMAC(theList: TStringList; theKey: string): string;
var
i, j, theLine, thePos: integer;
begin
theLine := -1;
for i := 0 to theList.Count - 1 do
begin
j := pos(theKey, theList.Strings[i]);
if j > 0 then
begin
theLine := i;
thePos := j + length(theKey) + 1;
end;
end;
if theLine > -1 then
result := ExtractSubStr(theList.Strings[theLine], thePos, [' ']);
end;
procedure TForm1.GetaddressButtonClick(Sender: TObject);
var
theProcess: TProcess;
theOutput: TStringList;
begin
DomainEdit.Text := GetDomainName;
HostEdit.Text := GetHostName;
theProcess := TProcess.Create(nil);
theProcess.Executable := 'ifconfig';
theProcess.Parameters.Add('en0');
theProcess.Options := theProcess.Options + [poWaitOnExit, poUsePipes];
theProcess.Execute;
theOutput := TStringList.Create;
theOutput.LoadFromStream(theProcess.Output);
MAC1Edit.Text := ExtractMAC(theOutput, 'ether');
theOutput.Free;
theProcess.Free;
theProcess := TProcess.Create(nil);
theProcess.Executable := 'ifconfig';
theProcess.Parameters.Add('en1');
theProcess.Options := theProcess.Options + [poWaitOnExit, poUsePipes];
theProcess.Execute;
theOutput := TStringList.Create;
theOutput.LoadFromStream(theProcess.Output);
MAC2Edit.Text := ExtractMAC(theOutput, 'ether');
theOutput.Free;
theProcess.Free;
theProcess := TProcess.Create(nil);
theProcess.Executable := 'ifconfig';
theProcess.Parameters.Add('fw0');
theProcess.Options := theProcess.Options + [poWaitOnExit, poUsePipes];
theProcess.Execute;
theOutput := TStringList.Create;
theOutput.LoadFromStream(theProcess.Output);
MAC3Edit.Text := ExtractMAC(theOutput, 'lladdr');
theOutput.Free;
theProcess.Free;
end;
This procedure fills the contents of three edits fields with the MAC addresses of two ethernet interfaces (en0 and en1) and one firewire interface (fw0). You may want to change the code as required.
See also the attached demo project for reference.