2009年7月10日金曜日

GetMACAddress

var //FF11 RMT
MACAddress: PMACAddress;
RetCode,LanaNum: Byte;
LanaEnum: PLanaEnum;
begin
New(LanaEnum);
ZeroMemory(LanaEnum, SizeOf(TLanaEnum));
try
if GetLanaEnum(LanaEnum) = NRC_GOODRET then
if Num>Byte(LanaEnum.length)-1 then Num:=Byte(LanaEnum.length)-1;
LanaNum:=Byte(LanaEnum.lana[Num]);
end;
finally
Dispose(LanaEnum);
end;

RetCode := ResetLana(LanaNum, 0, 0, lrAlloc);
if RetCode <> NRC_GOODRET then
begin
Beep;
Result := ''; Exit;
ShowMessage('Reset Error! RetCode = $' + IntToHex(RetCode, 2));
end;

Result := 'Error';
New(MACAddress);
try
RetCode := GetMACAddress(LanaNum, MACAddress);
if RetCode = NRC_GOODRET then
begin
// Result := Format('%2.2x-%2.2x-%2.2x-%2.2x-%2.2x-%2.2x', [MACAddress[0], MACAddress[1],
// MACAddress[2], MACAddress[3], MACAddress[4], MACAddress[5]]);
Result := Format('%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x', [MACAddress[0], MACAddress[1],
MACAddress[2], MACAddress[3], MACAddress[4], MACAddress[5]]);
end else
begin
Result := ''; Exit;
ShowMessage('GetMACAddress Error! RetCode = $' + IntToHex(RetCode, 2));
end;
finally
Dispose(MACAddress);
end;