On Thu, Dec 05, 2013 at 07:33:38PM +0800, Dennis Poon wrote:
> I tried to read the mac address in the captioned file path.
> In terminal, I can simply 'cat' and display the mac address.
> 
> In FPC, when I tried to use TFileStream to read it,
> 
>   FS := TFileStream.Create('/sys/class/net/eth1/address',
> fmOpenRead+fmShareDenyWrite);
> 
> it raised "stream read error"
> 
> If I tried to use TextFile and readln, it even halted the program.
> 
> My question is:
>   Why 'cat' command can easily display this special file 'address'
> but TFileStream cannot.
> 
> I was told to use this method to get the MAC address of a network
> card, what other methods are there?

While your method should work if that file actually exists, you probably
want to use libudev for enumerating and getting device information from
sysfs.  libudev will also enable you to get hotplug notification.

Henry
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to