------------ I apologise, I certainly made a mistake somewhere because after an other try your code works perfectly (not mine :-(). Thanks. ALEX ---------- "Steve" a �crit dans le message de news:wuirb.150012$Fm2.132677@attbi_s04... > Converting the example at > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/netbios/netbios_1l82.asp > to Ada: > > with Ada.Strings.Fixed; > with Ada.Text_IO; > with Win32.Nb30; > with Interfaces; > use Interfaces; > with Interfaces.C; > with Ada.Unchecked_Conversion; > > procedure Show_Mac_Address is > > use type Interfaces.C.unsigned_short; > use type Interfaces.C.unsigned_char; > > package UInt_Io is > new Ada.Text_IO.Modular_IO( Win32.UCHAR ); > > type NAME_BUFFER_ARRAY is array( 0 .. 29 ) of Win32.nb30.NAME_BUFFER; > > type AStat is > record > adapt : Win32.nb30.ADAPTER_STATUS; > nameBuffer : NAME_BUFFER_ARRAY; > end record; > pragma Convention( C, AStat ); > > type AstatAcc is access all Astat; > > function Conv is > new Ada.Unchecked_Conversion( AstatAcc, Win32.PUCHAR ); > > type Byte_Array_Type is array( Positive range <> ) of Unsigned_8; > > function Hex_Chars( Char_Data : Win32.UCHAR ) return String is > str_buffer : String( 1 .. 32 ); > first_hash : Natural; > last_hash : Natural; > begin > UInt_Io.Put( str_buffer, Char_Data, 16 ); > first_hash := Ada.Strings.Fixed.Index( str_buffer, "#", > Ada.Strings.Forward ); > last_hash := Ada.Strings.Fixed.Index( str_buffer, "#", > Ada.Strings.Backward ); > return str_buffer( first_hash + 1 .. last_hash - 1 ); > end Hex_Chars; > > ncb : aliased Win32.Nb30.NCB; > Ncb_Alias : Byte_Array_Type( 1 .. ncb'Size/8 ); > for Ncb_Alias'Address use ncb'Address; > Return_Code : Win32.UCHAR; > Adapter : aliased AStat; > begin > Ncb_Alias := ( others => 0 ); > ncb.ncb_command := Win32.Nb30.NCBRESET; > ncb.ncb_lana_num := 0; > > Return_Code := Win32.Nb30.Netbios( ncb'UNCHECKED_ACCESS ); > Ada.Text_IO.Put( "The NCBRESET return code is: " & Hex_Chars( > Return_Code ) ); > Ada.Text_IO.New_Line; > > Ncb_Alias := ( others => 0 ); > ncb.ncb_command := Win32.Nb30.NCBASTAT; > ncb.ncb_lana_num := 0; > ncb.ncb_callname := ( 0 => Character'Pos('*'), others => Character'Pos(' > ') ); > ncb.ncb_buffer := Conv( Adapter'Access ); > ncb.ncb_length := Adapter'Size / 8; > > Return_Code := Win32.Nb30.Netbios( ncb'Unchecked_Access ); > > Ada.Text_IO.Put( "The NCBASTAT return code is: " & Hex_Chars( > Return_Code ) ); > Ada.Text_IO.New_Line; > > if Return_Code = 0 then > Ada.Text_IO.Put( "The Ethernet Number is: " ); > Ada.Text_IO.Put( Hex_Chars( Adapter.adapt.adapter_address(0) ) & "-" & > Hex_Chars( Adapter.adapt.adapter_address(1) ) & "-" & > Hex_Chars( Adapter.adapt.adapter_address(2) ) & "-" & > Hex_Chars( Adapter.adapt.adapter_address(3) ) & "-" & > Hex_Chars( Adapter.adapt.adapter_address(4) ) & "-" & > Hex_Chars( Adapter.adapt.adapter_address(5) ) ); > Ada.Text_IO.New_Line; > end if; > > end Show_Mac_Address; > > For things to link correctly with GNAT you must specify the netabp32 > library: > > gnatmake Show_Mac_Address -largs -lnetapi32 > > I hope this helps, > Steve > (The Duck) > > > "Alex Xela" wrote in message > news:3fad244e$0$27572$626a54ce@news.free.fr... > > Hi, > > > > I 'm looking for some Ada stuff to get the Mac Address under WindowsNT/XP > > (using bindingWin32 -> function Win32.Nb30.Netbios()) > > > > I tried in vain to write it, but honestly, I'm not a win32 API guru...... > > > > Thanks. > > > > Alex. > > > > > >