Такая беда, при
var
str:TStringList;
begin
str:=TStringList.Create;
str.LoadFromFile('mac.txt');
Memo1.Text:=str.Text;
str.Free;
end;
теряется большая часть информации. Вот код при помощи которого производилась запись mak.txt:
program GetMac;
uses
Windows,
SysUtils,
Classes;
const
MAX_ADAPTER_NAME_LENGTH = 256;
MAX_ADAPTER_DESCRIPTION_LENGTH = 128;
MAX_ADAPTER_ADDRESS_LENGTH = 8;
type
PIP_ADDRESS_STRING = ^IP_ADDRESS_STRING;
IP_ADDRESS_STRING = array[0..15] of char;
PIP_ADDR_STRING = ^IP_ADDR_STRING;
IP_ADDR_STRING = record
Next: PIP_ADDR_STRING;
IpAddress: IP_ADDRESS_STRING;
IpMask: IP_ADDRESS_STRING;
Context: DWORD;
end;
PIP_ADAPTER_INFO = ^IP_ADAPTER_INFO;
IP_ADAPTER_INFO = record
Next: PIP_ADAPTER_INFO;
ComboIndex: DWORD;
AdapterName: array[1..MAX_ADAPTER_NAME_LENGTH + 4] of char;
Description: array[1..MAX_ADAPTER_DESCRIPTION_LENGTH + 4] of char;
AddressLength: UINT;
Address: array[1..MAX_ADAPTER_ADDRESS_LENGTH] of byte;
Index: DWORD;
aType: UINT;
DHCPEnabled: UINT;
CurrentIPAddress: PIP_ADDR_STRING;
IPAddressList: IP_ADDR_STRING;
GatewayList: IP_ADDR_STRING;
DHCPServer: IP_ADDR_STRING;
HaveWINS: BOOL;
PrimaryWINSServer: IP_ADDR_STRING;
SecondaryWINSServer: IP_ADDR_STRING;
LeaseObtained: LongInt;
LeaseExpires: LongInt;
SpareStuff: array [1..200] of char;
end;
function GetAdaptersInfo(pAdapterInfo: PIP_ADAPTER_INFO;
pOutBufLen: PULONG): DWORD; stdcall;
external 'Iphlpapi.dll' name 'GetAdaptersInfo';
const
OutBufLen: ULONG = 2000;
AddrLen = 6;
var
AdapterInfo: IP_ADAPTER_INFO;
Result: DWORD;
i: integer;
Next: PIP_ADAPTER_INFO;
str:TStringList;
mac:String;
begin
str:=TStringList.Create;
Result:= GetAdaptersInfo(@AdapterInfo, @OutBufLen);
if Result = 0 then
begin
Next:= @AdapterInfo;
repeat
str.Add('Description: '+Next^.Description);
for i := 0 to AddrLen do
begin
mac:=mac+IntToHex(Next^.Address[i],2);
if i <> AddrLen then mac:=mac+'-';
end;
str.Add('MAC address: '+mac);
Next:= Next^.Next;
str.Add('');
until Next = nil;
end
else str.Add('Error. Result code: '+IntToStr(Result));
str.SaveToFile('mac.txt');
str.Free;
end.