Boa noite
Gostaria de saber se existe alguma no Harbour que retorne o mac address da placa de rede e se funciona Windows e Linux.
Obrigado.
MacAddress da placa de rede
Moderador: Moderadores
- Itamar M. Lins Jr.
- Administrador

- Mensagens: 7929
- Registrado em: 30 Mai 2007 11:31
- Localização: Ilheus Bahia
- Curtiu: 1 vez
MacAddress da placa de rede
Ola!
Alguma ? existe!
Linux
Pesquise no forum que tem mais respostas p/ essa pergunta.
Saudações,
Itamar M. Lins Jr.
Alguma ? existe!
Código: Selecionar todos
*-----------------------------
PROCEDURE Main
*-----------------------------
getMacAddress()
RETURN
*-----------------------------
FUNCTION getMacAddress()
*-----------------------------
Local oWmi := WmiService(), oAdapter, ii := 0
for each oAdapter in oWmi:ExecQuery("Select * from Win32_NetworkAdapter where physicaladapter=true")
if !empty(oAdapter:MACAddress)
++ii
? str(ii,2,0)+ '. ' + ' Interface : ' + oAdapter:description
? space(4) + 'MACAddress : ' + oAdapter:MACAddress
?
endif
next
oWMI := Nil
Return Nil
*-----------------------------
FUNCTION WMIService()
*-----------------------------
local oWMI, oLocator
oLocator := win_oleCreateObject( "wbemScripting.SwbemLocator" )
oWMI := oLocator:ConnectServer()
Return oWMI
Please complile with -lhbwin (hbwin library).
Evangelos
Código: Selecionar todos
for Linux!, harbour can do:
HB_INETIFINFO()[nNic][8]
ẃhere:
nNic is number of NIC interface.
As we have in Linux as first interface often this virtual 'loopback', try '2'.
Build around a check for len of returned 2dim array.
And this '8' stands for HB_SOCKET_IFINFO_HWADDR
may look changelog for info about other elements...
best regards
Rolf
Saudações,
Itamar M. Lins Jr.
Saudações,
Itamar M. Lins Jr.
Itamar M. Lins Jr.
