Page 3 of 4

Re: LAN info - Windows only

Posted: Sat Aug 23, 2014 2:31 pm
by skywalk
FROM:
doctorized or infratec wrote:

Code: Select all

Procedure.s TranslateASCII(*Ascii, StringByteLength.i=-1)
  ProcedureReturn PeekS(*Ascii, StringByteLength, #PB_Ascii)
EndProcedure
TO: remember PeekS/PokeS uses num characters, not bytes.

Code: Select all

Procedure.s TranslateASCII(*Ascii, numChars.i=-1)
  ProcedureReturn PeekS(*Ascii, numChars, #PB_Ascii)
EndProcedure

Re: LAN info - Windows only

Posted: Sat Aug 23, 2014 3:07 pm
by minimy
Work fantastic!!.. :D
Great aportation. many thanks! +1

Win 7 - PB 5.21

Re: LAN info - Windows only

Posted: Sat Aug 23, 2014 6:03 pm
by infratec

Code: Select all

Procedure.s TranslateASCII(*Ascii, numChars.i=-1)
  ProcedureReturn PeekS(*Ascii, numChars, #PB_Ascii)
EndProcedure


Test$ = Space(10)

PokeA(@Test$ + 0, $31)
PokeA(@Test$ + 1, $DC)  ; german ue
PokeA(@Test$ + 2, $DF)  ; german ss
PokeA(@Test$ + 3, $00)
PokeA(@Test$ + 4, $00)


Debug TranslateASCII(@Test$, 3)
works correct with german special characters.

Bernd

Re: LAN info - Windows only

Posted: Sun Aug 24, 2014 12:58 pm
by doctorized
infratec wrote:

Code: Select all

Procedure.s TranslateASCII(*Ascii, numChars.i=-1)
  ProcedureReturn PeekS(*Ascii, numChars, #PB_Ascii)
EndProcedure


Test$ = Space(10)

PokeA(@Test$ + 0, $31)
PokeA(@Test$ + 1, $DC)  ; german ue
PokeA(@Test$ + 2, $DF)  ; german ss
PokeA(@Test$ + 3, $00)
PokeA(@Test$ + 4, $00)


Debug TranslateASCII(@Test$, 3)
works correct with german special characters.

Bernd
You didn't understand me. I wanted to say that users who have motherboards with nForce chipset (and LAN card is part of this chipset) and their OS in not english but German or Spanish for example, they may have the same problem with me, they may not be able to get the data correctly. Of cource PokeA() handles special chars successfully but do GetNetworkParams_() and GetIfTable_() return them correctly?

I did a test. I ran this code with Unicode enabled:

Code: Select all

a.s ="Ελεγκτής δικτύου"; network controller in greek language
For i=1 To Len(a)
	Debug Hex(Asc(Mid(a,i,1)))
Next
and these values where returned:

Code: Select all

395
3BB
3B5
3B3
3BA
3C4
3AE
3C2
20
3B4
3B9
3BA
3C4
3CD
3BF
3C5
without unicode $3F is returned for every char, except space ($20). Is there any codepage problem or something like that?

Re: LAN info - Windows only

Posted: Sun Aug 24, 2014 1:55 pm
by luis
doctorized wrote: without unicode $3F is returned for every char, except space ($20). Is there any codepage problem or something like that?
Do you have UTF-8 enabled in the ide ?
If you select "File format -> plain text" can you paste the greek text above and it's still readable ?

Because if you have UTF-8 enabled maybe PB when doing the string assignment see a utf-8 string forced inside an ascii string, and so all the bytes exceeding the ascii range (all of the above excluding the space) are replaced with a question mark ($3F).

Re: LAN info - Windows only

Posted: Sun Aug 24, 2014 2:19 pm
by doctorized
luis wrote:Do you have UTF-8 enabled in the ide ?
If you select "File format -> plain text" can you paste the greek text above and it's still readable ?
In most of my .pb files "plain text" is selected but in some others like every new file utf-8 is enabled (maybe it happens as unicode is enabled). In my test, utf-8 was selected and when I changed it to plain text all greek letters turned to "?". I erased them and wrote them again. They were writen correctly, readable. Now my test code returns ascii values but I still have no idea how to use the chars returned from the API calls to create the real chars that should retuned.

Re: LAN info - Windows only

Posted: Sun Aug 24, 2014 2:44 pm
by luis
doctorized wrote: I erased them and wrote them again. They were writen correctly, readable. Now my test code returns ascii values...
OK, then the mistery of the string is solved (it was a unicode sting converted to ascii in the best way possible).
doctorized wrote: but I still have no idea how to use the chars returned from the API calls to create the real chars that should retuned.
Sorry but the thread has too much different code from different people for my attention span.

Can you make the smallest possible program exhibiting the specific problem ?

Uhm.. but maybe it would be useless, I've tried on a PC with Greek language enabled but the name of the network adapter is reported in english anyway, so...it's not enough. Maybe one need to set the locale too, or to install the drivers with the Greek locale already enabled as changing it afterwards is not enough. I don't know.

Re: LAN info - Windows only

Posted: Sun Aug 24, 2014 7:34 pm
by doctorized
luis wrote:Can you make the smallest possible program exhibiting the specific problem ?
GetNetworkParams_() is not giving the card's name at all. Code:

Code: Select all

hMod.i = OpenLibrary(#PB_Any,"iphlpapi.dll")
If GetFunction(hMod, "GetAdaptersInfo") <> 0 
	lErrors = GetAdaptersInfo_(0, @lBufferLength)
	Dim aBuffer.a(lBufferLength)
	lErrors = GetAdaptersInfo_(@aBuffer(0), @lBufferLength)
	If lErrors = #ERROR_SUCCESS
		Debug PeekS(@aBuffer(0)+268,132,#PB_Ascii);for every card, we have the card's name starting from byte 268 of the structure for PB x86.
		Debug PeekS(@aBuffer(0)+272,132,#PB_Ascii);for every card, we have the card's name starting from byte 272 of the structure for PB x64.
		ShowMemoryViewer(@aBuffer(0),lBufferLength)
	EndIf
Else
	MessageRequester("error","Could not connect with 'iphlpapi.dll'.")
EndIf
CloseLibrary(hMod)
GetIfTable_() returns the name of every card but greek chars are altered. Code:

Code: Select all

hMod.i = OpenLibrary(#PB_Any,"iphlpapi.dll")
If GetFunction(hMod, "GetIfTable") <> 0
	lErrors = GetIfTable_(0, @lSize, 0)
	Dim aaBuffer.a(lSize)
	lErrors = GetIfTable_(@aaBuffer(0), @lSize, 0)
	ShowMemoryViewer(@aaBuffer(0), lSize)
Else
	MessageRequester("error","Could not connect with 'iphlpapi.dll'.")
EndIf
CloseLibrary(hMod)
I don't think I can make something smaller. By looking in the memory viewer's window we can see the problem.

Re: LAN info - Windows only

Posted: Sun Aug 24, 2014 8:56 pm
by luis
doctorized wrote: GetNetworkParams_() is not giving the card's name at all.
Uhmm.. here works... sorta.
But there is something I've changed in the structures since I had different results in x86 and x64, now I get the same data.

I'm not sure it's all correct, it would be better to verify the sizes with a C compiler, but try this one and see if you get something different.

Code: Select all

;  typedef struct _IP_ADAPTER_INFO {
;    struct _IP_ADAPTER_INFO  *Next;
;    DWORD                   ComboIndex;
;    char                    AdapterName[MAX_ADAPTER_NAME_LENGTH + 4];
;    char                    Description[MAX_ADAPTER_DESCRIPTION_LENGTH + 4];
;    UINT                    AddressLength;
;    BYTE                    Address[MAX_ADAPTER_ADDRESS_LENGTH];
;    DWORD                   Index;
;    UINT                    Type;
;    UINT                    DhcpEnabled;
;    PIP_ADDR_STRING         CurrentIpAddress;
;    IP_ADDR_STRING          IpAddressList;
;    IP_ADDR_STRING          GatewayList;
;    IP_ADDR_STRING          DhcpServer;
;    BOOL                    HaveWins;
;    IP_ADDR_STRING          PrimaryWinsServer;
;    IP_ADDR_STRING          SecondaryWinsServer;
;    time_t                  LeaseObtained;
;    time_t                  LeaseExpires;
;  } IP_ADAPTER_INFO, *PIP_ADAPTER_INFO;


; typedef struct _IP_ADDR_STRING {
;   struct _IP_ADDR_STRING  *Next;
;   IP_ADDRESS_STRING      IpAddress;
;   IP_MASK_STRING         IpMask;
;   DWORD                  Context;
; } IP_ADDR_STRING, *PIP_ADDR_STRING;

#MAX_ADAPTER_NAME_LENGTH = 256
#MAX_ADAPTER_DESCRIPTION_LENGTH = 128
#MAX_ADAPTER_ADDRESS_LENGTH = 8

Structure IP_ADDR_STRING Align #PB_Structure_AlignC 
    *NextAdapter
    IpAddress.a[16]
    IpMask.a[16]
    Context.l
 EndStructure
 
Structure IP_ADAPTER_INFO Align #PB_Structure_AlignC 
    *Next.IP_ADAPTER_INFO
    ComboIndex.l
    AdapterName.a[#MAX_ADAPTER_NAME_LENGTH + 4] 
    Description.a[#MAX_ADAPTER_DESCRIPTION_LENGTH + 4]
    AddressLength.l
    Address.a[#MAX_ADAPTER_ADDRESS_LENGTH]
    index.l
    Type.l
    DhcpEnabled.l
    *CurrentIpAddress
    IpAddressList.IP_ADDR_STRING
    GatewayList.IP_ADDR_STRING
    DhcpServer.IP_ADDR_STRING
    HaveWINS.l
    PrimaryWinsServer.IP_ADDR_STRING
    SecondaryWinsServer.IP_ADDR_STRING
    LeaseObtained.i
    LeaseExpires.i
 EndStructure

Debug OffsetOf(IP_ADAPTER_INFO\Description) ; offset is 268 (x86), 272 (x64)

hMod.i = OpenLibrary(#PB_Any,"iphlpapi.dll")
If GetFunction(hMod, "GetAdaptersInfo") <> 0
    lErrors = GetAdaptersInfo_(0, @lBufferLength)
    *p.IP_ADAPTER_INFO = AllocateMemory(lBufferLength)
    lErrors = GetAdaptersInfo_(*p, @lBufferLength)
    If lErrors = #ERROR_SUCCESS
        CallDebugger
        ShowMemoryViewer(@*p\Description,64)
        ShowMemoryViewer(@*p\AddressLength,4)
        ShowMemoryViewer(@*p\Address,8)
        ShowMemoryViewer(@*p\IpAddressList\IpAddress,16)
        ShowMemoryViewer(@*p\IpAddressList\IpMask,16)
        Debug *p\HaveWINS
        ShowMemoryViewer(@*p\LeaseObtained,SizeOf(Integer))        
        ShowMemoryViewer(@*p\LeaseExpires,SizeOf(Integer))        
        Debug PeekS(@*p\Description,-1,#PB_Ascii)
   EndIf
EndIf
CloseLibrary(hMod)
This is the buffer I get:

Code: Select all

005B07D4  54 0A 5B 00 0A 00 00 00 7B 36 44 32 44 30 36 43  T.[.....{6D2D06C
005B07E4  38 2D 32 44 34 32 2D 34 33 41 36 2D 38 46 38 38  8-2D42-43A6-8F88
005B07F4  2D 31 38 38 38 44 30 33 34 35 41 38 34 7D 00 00  -1888D0345A84}..
005B0804  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
005B0814  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
005B0824  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
005B0834  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
005B0844  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
005B0854  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
005B0864  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
005B0874  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
005B0884  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
005B0894  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
005B08A4  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
005B08B4  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
005B08C4  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
005B08D4  00 00 00 00 00 00 00 00 00 00 00 00 52 65 61 6C  ............Real
005B08E4  74 65 6B 20 50 43 49 65 20 47 42 45 20 46 61 6D  tek PCIe GBE Fam
005B08F4  69 6C 79 20 43 6F 6E 74 72 6F 6C 6C 65 72 00 00  ily Controller..
005B0904  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
005B0914  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
005B0924  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
005B0934  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
005B0944  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
005B0954  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
005B0964  06 00 00 00 00 25 22 68 E4 EF 00 00 0A 00 00 00  .....%"häï......
005B0974  06 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00  ................
005B0984  31 39 32 2E 31 36 38 2E 30 2E 31 00 00 00 00 00  192.168.0.1.....
005B0994  32 35 35 2E 32 35 35 2E 32 35 35 2E 30 00 00 00  255.255.255.0...
005B09A4  C0 A8 00 01 00 00 00 00 31 39 32 2E 31 36 38 2E  ˬ......192.168.
005B09B4  30 2E 31 30 30 00 00 00 32 35 35 2E 32 35 35 2E  0.100...255.255.
005B09C4  32 35 35 2E 32 35 35 00 C0 A8 00 64 00 00 00 00  255.255.ˬ.d....
005B09D4  31 39 32 2E 31 36 38 2E 30 2E 31 30 30 00 00 00  192.168.0.100...
005B09E4  32 35 35 2E 32 35 35 2E 32 35 35 2E 32 35 35 00  255.255.255.255.
005B09F4  C0 A8 00 64 00 00 00 00 00 00 00 00 00 00 00 00  ˬ.d............
005B0A04  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
005B0A14  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
005B0A24  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
005B0A34  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
005B0A44  00 00 00 00 00 00 00 00 AD B0 F9 53 2D 02 FB 53  ........­°ùS-.ûS
005B0A54  00 00 00 00 18 00 00 00 7B 32 44 35 32 38 37 30  ........{2D52870
005B0A64  42 2D 43 36 36 44 2D 34 34 35 37 2D 41 35 39 43  B-C66D-4457-A59C
005B0A74  2D 45 33 44 34 41 46 45 37 35 39 30 42 7D 00 00  -E3D4AFE7590B}..
005B0A84  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
005B0A94  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
005B0AA4  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
005B0AB4  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
005B0AC4  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
005B0AD4  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
005B0AE4  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
005B0AF4  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
005B0B04  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
005B0B14  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
005B0B24  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
005B0B34  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
005B0B44  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
005B0B54  00 00 00 00 00 00 00 00 00 00 00 00 56 69 72 74  ............Virt
005B0B64  75 61 6C 42 6F 78 20 48 6F 73 74 2D 4F 6E 6C 79  ualBox Host-Only
005B0B74  20 45 74 68 65 72 6E 65 74 20 41 64 61 70 74 65   Ethernet Adapte
005B0B84  72 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  r...............
005B0B94  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
005B0BA4  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
005B0BB4  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
005B0BC4  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
005B0BD4  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
005B0BE4  06 00 00 00 08 00 27 00 B4 2F 00 00 18 00 00 00  ......'.´/......
005B0BF4  06 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
005B0C04  31 39 32 2E 31 36 38 2E 35 36 2E 31 00 00 00 00  192.168.56.1....
005B0C14  32 35 35 2E 32 35 35 2E 32 35 35 2E 30 00 00 00  255.255.255.0...
005B0C24  C0 A8 38 01 00 00 00 00 30 2E 30 2E 30 2E 30 00  ˬ8.....0.0.0.0.
005B0C34  00 00 00 00 00 00 00 00 32 35 35 2E 32 35 35 2E  ........255.255.
005B0C44  32 35 35 2E 32 35 35 00 00 00 00 00 00 00 00 00  255.255.........
005B0C54  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
005B0C64  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
005B0C74  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
005B0C84  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
005B0C94  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
005B0CA4  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
005B0CB4  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
005B0CC4  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................

Re: LAN info - Windows only

Posted: Mon Aug 25, 2014 9:44 am
by doctorized
Your cards' names are in english by the manufacturer (or so) so you do see nothing strange. You do not have nForce motherboard to see what I see. nForce users with no english OS will be our solution. I have a friend, here in Greece who could help but I cannot find him, he may be on vacation. :(

Re: LAN info - Windows only

Posted: Tue Aug 26, 2014 4:21 pm
by doctorized
I found something!!! The chars that GetIfTable_() returns are the ascii codes for code page 737.
For example, "E" (greek upper case epsilon) has ascii 197 ($C5) in greek windows. In code page 737 "E" has ascii 132 ($84). This value is what I took back. The point is this now: how do I convert chars from code page 737 to 1253?
Code page 737 is my active one but in applications code page 1253 is used.

This is the page that I found the info: http://www.ascii-codes.com/cp737.html

Re: LAN info - Windows only

Posted: Tue Sep 09, 2014 6:08 pm
by doctorized
The code is updated. It must run fine now. Test it!! Do not forget to turn unicode on!

Code: Select all

#MIB_IF_TYPE_OTHER = 1
#MIB_IF_TYPE_ETHERNET = 6
#MIB_IF_TYPE_TOKENRING = 9
#MIB_IF_TYPE_FDDI = 15
#MIB_IF_TYPE_PPP = 23
#MIB_IF_TYPE_LOOPBACK = 24
#MIB_IF_TYPE_SLIP = 28

#MIB_IF_OPER_STATUS_NON_OPERATIONAL = 0
#MIB_IF_OPER_STATUS_UNREACHABLE = 1
#MIB_IF_OPER_STATUS_DISCONNECTED = 2
#MIB_IF_OPER_STATUS_CONNECTING = 3
#MIB_IF_OPER_STATUS_CONNECTED = 4
#MIB_IF_OPER_STATUS_OPERATIONAL = 5

#BROADCAST_NODETYPE = 1
#PEER_TO_PEER_NODETYPE = 2
#MIXED_NODETYPE = 4
#HYBRID_NODETYPE = 8

Structure IP_ADDR_STRING1
    NextAdapter.i
    IpAddress.a[16];IP_ADDRESS_STRING
    IpMask.a[16];IP_ADDRESS_STRING
    Context.i
 EndStructure
 
 Structure FIXED_INFO1
    HostName.a[132]            ;MAX_HOSTNAME_LEN + 4
    DomainName.a[132]         ;MAX_DOMAIN_NAME_LEN + 4
    CurrentDnsServer.i
    DnsServerList.IP_ADDR_STRING1
    NodeType.l
    ScopeId.a[260]             ;MAX_SCOPE_ID_LEN + 4
    EnableRouting.l
    EnableProxy.l
    EnableDns.l
 EndStructure
 
Structure IP_ADAPTER_INFO1
    NextAdapter.i
    ComboIndex.l
    AdapterName.a[260] ;MAX_ADAPTER_NAME_LENGTH + 4
    Description.a[132] ;MAX_ADAPTER_DESCRIPTION_LENGTH + 4
    AddressLength.l
    Address.a[8] ;MAX_ADAPTER_ADDRESS_LENGTH
    index.l
    Type.l
    DhcpEnabled.i
    CurrentIpAddress.i
    IpAddressList.IP_ADDR_STRING1
    GatewayList.IP_ADDR_STRING1
    DhcpServer.IP_ADDR_STRING1
    HaveWINS.i
    PrimaryWinsServer.IP_ADDR_STRING1
    SecondaryWinsServer.IP_ADDR_STRING1
    LeaseObtained.i
    LeaseExpires.i
 EndStructure
 
 Structure MIB_IFROW2
  StructureUnion
    Value.q
    Value2.q
  EndStructureUnion
  InterfaceIndex.l
  InterfaceGuid.a[16]
  Alias.w[257]
  Description.w[257]
  PhysicalAddressLength.l
  PhysicalAddress.a[32]
  PermanentPhysicalAddress.a[32]
  Mtu.l
  Type.l
  TunnelType.l;
  MediaType.l
  PhysicalMediumType.l
  AccessType.l
  DirectionType.l
  InterfaceAndOperStatusFlags.l
  OperStatus.l
  AdminStatus.l
  MediaConnectState.l
  NetworkGuid.a[16]
  ConnectionType.q
  TransmitLinkSpeed.q
  ReceiveLinkSpeed.q
  InOctets.q
  InUcastPkts.q
  InNUcastPkts.q
  InDiscards.q
  InErrors.q
  InUnknownProtos.q
  InUcastOctets.q
  InMulticastOctets.q
  InBroadcastOctets.q
  OutOctets.q
  OutUcastPkts.q
  OutNUcastPkts.q
  OutDiscards.q
  OutErrors.q
  OutUcastOctets.q
  OutMulticastOctets.q
  OutBroadcastOctets.q
  OutQLen.q
EndStructure 

Structure MIB_IFROW
    wszName.a[512]
    dwIndex.l
    dwType.l
    dwMtu.l
    dwSpeed.l
    dwPhysAddrLen.l
    bPhysAddr.a[8]
    dwAdminStatus.l
    dwOperStatus.l
    dwLastChange.l
    dwInOctets.l
    dwInUcastPkts.l
    dwInNUcastPkts.l
    dwInDiscards.l
    dwInErrors.l
    dwInUnknownProtos.l
    dwOutOctets.l
    dwOutUcastPkts.l
    dwOutNUcastPkts.l
    dwOutDiscards.l
    dwOutErrors.l
    dwOutQLen.l
    dwDescrLen.l
    bDescr.a[256]
 EndStructure

Structure MIB_IFTABLE1
    dwNumEntries.l
    table.MIB_IFROW[256]
 EndStructure
 
Structure NetWorkInfo
index.l
HostName.s
DomainName.s
DNSIPAdd.s[11]
nod.s
ScopeID.s
DNSE.s
ProxyE.s
RoutE.s
Conx.s
AdapterName.s[11]
Type.s[11]
Speed.s[11]
sMTU.s[11]
packsS.s[11]
bytesS.s[11]
packsR.s[11]
bytesR.s[11]
status.s[11]
IPAddr.s[11]
SubMask.s[11]
Addr.s[11]
Indx.s[11]
DHCPE.s[11]
DHCPIPAddr.s[11]
DHCPIPMask.s[11]
DHCPLObt.s[11]
DHCPLExp.s[11]
GateIPAddress.s[11]
GateIPMask.s[11]
HaveWINS.s[11]
PWINSIPAddress.s[11]
PWINSIPMask.s[11]
SWINSIPAddress.s[11]
SWINSIPMask.s[11]
HWInterface.s[11]
FilterInterface.s[11]
HasConntectorPresent.s[11]
PortAuthenticated.s[11]
MediaConnected.s[11]
Paused.s[11]
LowPower.s[11]
EndPoint.s[11]
EndStructure

Global MIB_IFTABLE.MIB_IFTABLE1
 Global NewList NICs.s()
 Global GroupDemicals.s = ","
 Global GroupThousands.s = "."
 Global LANInfo.NetWorkInfo
 
 Procedure.d int32_uint32(lValue.l)
int32uint32.l
    If lValue < 0
        int32uint32 = lValue + $100000000
    Else
        int32uint32 = lValue
    EndIf
    ProcedureReturn int32uint32
 EndProcedure
 
 Procedure.s c2str(num.d, demical.l=0)
ProcedureReturn ReplaceString(StrD(num,demical), ".", GroupDemicals)
EndProcedure

Procedure.s FormatByteSize(n.q)
  Protected s.s=Str(n)
  Protected len=Len(s)
  Protected ret.s
 
  For i=0 To len-1
    If i And Not i%3 : ret="." + ret : EndIf; "." is the greek symbol for separating thousands. Use your own.
    ret= Mid(s,len-i,1) +ret
  Next
 
  ProcedureReturn ret
EndProcedure

Procedure.s SpaceDivider(space.q)
tm.s:mt.d=space
If mt>1000: mt / 1024:tm = " KB":EndIf
If mt>1000: mt / 1024:tm = " MB":EndIf
If mt>1000: mt / 1024:tm = " GB":EndIf
If mt>1000: mt / 1024:tm = " TB":EndIf
ProcedureReturn ReplaceString(StrD(mt,3), ".", GroupDemicals) + tm
EndProcedure

Procedure.s GetRegString(hKey.l, strPath.s, strValue.s, RegType.l=2)
KeyHand.l:datatype.l:lResult.l
Dim strBuf.a(1):lDataBufSize.l
intZeroPos.l:tempV.l:mm.l
RegOpenKeyEx_(hKey, strPath, 0, 1, @KeyHand)
lResult = RegQueryValueEx_(KeyHand, strValue, 0, @lValueType, 0, @lDataBufSize)
If lDataBufSize > 0
	*Buffer = AllocateMemory(lDataBufSize)
Else 
	ProcedureReturn
EndIf
lResult = RegQueryValueEx_(KeyHand, @strValue, 0, @RegType, *Buffer, @lDataBufSize)
If lResult = #ERROR_SUCCESS
	ProcedureReturn PeekS(*Buffer,-1,#PB_Unicode)
EndIf
EndProcedure

Procedure LAN()
hMod.i = LoadLibrary_("iphlpapi.dll")
	lErrors = GetAdaptersInfo_(0, @lBufferLength)
	CardsFound.i = lBufferLength/SizeOf(IP_ADAPTER_INFO1)
	Dim IP_ADAPTER_INFO.IP_ADAPTER_INFO1(CardsFound)
	lErrors = GetAdaptersInfo_(@IP_ADAPTER_INFO(0), @lBufferLength)
	If lErrors <> #ERROR_SUCCESS: MessageRequester("Error","GetAdaptersInfo_() error."): ProcedureReturn: EndIf
	lBufferPos.l
	For i=0 To CardsFound-1
		LANInfo\AdapterName[i] = PeekS(@IP_ADAPTER_INFO(i)\Description,-1,#PB_Ascii)
		If LANInfo\AdapterName[i] = ""
			aaa.s = PeekS(@IP_ADAPTER_INFO(i)\AdapterName,-1,#PB_Ascii)
			For ii=0 To 100
				If GetRegString(#HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVErsion\NetworkCards\" + Str(ii), "ServiceName") = aaa
					LANInfo\AdapterName[i] = GetRegString(#HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVErsion\NetworkCards\" + Str(ii), "Description")
				EndIf
			Next
		EndIf
	Next
tmp.s
tmp2.d
lErrors = GetIfTable_(@MIB_IFTABLE, @lSize, 0)
lSize = SizeOf(MIB_IFTABLE1)
lErrors = GetIfTable_(@MIB_IFTABLE, @lSize, 0)
If MIB_IFTABLE\dwNumEntries <> 0
	GetIfTables.i = MIB_IFTABLE\dwNumEntries; we need to know how many are the tables to retrieve them.
EndIf

Dim If_entry.MIB_IFROW2(GetIfTables - 1)

If OSVersion() >= #PB_OS_Windows_Vista
	If_entry2.MIB_IFROW2
	Lib_iphlpapi = OpenLibrary(#PB_Any,"iphlpapi.dll")
	If Lib_iphlpapi<> 0
		GetIfEntry=GetFunction(Lib_iphlpapi,"GetIfEntry2")
	EndIf
	CloseLibrary(Lib_iphlpapi)
	For ii=1 To GetIfTables
		If_entry2\InterfaceIndex = ii
		CallFunctionFast(GetIfEntry, @If_entry2)
		CopyMemory(@If_entry2, @If_entry(ii-1),SizeOf(MIB_IFROW2))
		ClearStructure(@If_entry2, MIB_IFROW2)
	Next
Else
	If_entry1.MIB_IFROW
	For ii=1 To GetIfTables
		IF_entry1\dwIndex = ii
		GetIfEntry_(@If_entry1)
		CopyMemory(@If_entry1\bDescr, @If_entry(ii-1)\Description, 256)
		CopyMemory(@If_entry1\bPhysAddr, @If_entry(ii-1)\PhysicalAddress, 8)
		If_entry(ii-1)\AdminStatus = If_entry1\dwAdminStatus
		If_entry(ii-1)\InterfaceIndex = If_entry1\dwIndex
		If_entry(ii-1)\InDiscards = If_entry1\dwInDiscards
		If_entry(ii-1)\InNUcastPkts = If_entry1\dwInNUcastPkts
		If_entry(ii-1)\InOctets = If_entry1\dwInOctets
		If_entry(ii-1)\InUcastPkts = If_entry1\dwInUcastPkts
		If_entry(ii-1)\Mtu = If_entry1\dwMtu
		If_entry(ii-1)\OperStatus = If_entry1\dwOperStatus
		If_entry(ii-1)\OutNUcastPkts = If_entry1\dwOutNUcastPkts
		If_entry(ii-1)\OutOctets = If_entry1\dwOutOctets
		If_entry(ii-1)\OutUcastPkts = If_entry1\dwOutUcastPkts
		If_entry(ii-1)\TransmitLinkSpeed = If_entry1\dwSpeed
	Next
EndIf

	xx = 0
	Dim FIXED_INFO.FIXED_INFO1(9)
	lBufferLength = SizeOf(FIXED_INFO1)*9
	lErrors = GetNetworkParams_(@FIXED_INFO(), @lBufferLength)
	For i=0 To 9
		With FIXED_INFO(i)
			If \HostName = 0:Break:EndIf
		IP_ADDR_STRING.IP_ADDR_STRING1
		LANInfo\HostName = PeekS(@\Hostname,-1,#PB_Ascii)
		LANInfo\DomainName = PeekS(@\DomainName,-1,#PB_Ascii)
		If \EnableDns = 1:  LANInfo\DNSE = "Yes": Else: LANInfo\DNSE = "No": EndIf
		LANInfo\DNSIPAdd[xx] = PeekS(@\DnsServerList\IpAddress,-1,#PB_Ascii)
		lNext.l = \DnsServerList\NextAdapter
		While aa.l=0
			If lNext <> 0 
				If IsBadReadPtr_(lNext, SizeOf(IP_ADDR_STRING1)) = #False
					MoveMemory(@lNext, @IP_ADDR_STRING, SizeOf(IP_ADDR_STRING1))
				EndIf
				If lNext <> IP_ADDR_STRING\NextAdapter 
					lNext = IP_ADDR_STRING\NextAdapter
					xx = xx + 1
					LANInfo\DNSIPAdd[xx] = PeekS(@IP_ADDR_STRING\IpAddress[0],-1,#PB_Ascii)
				Else
					aa=1
				EndIf
			Else
				aa=1
			EndIf
		Wend
		Select \NodeType
			Case #BROADCAST_NODETYPE: LANInfo\nod = "Broadcast"
			Case #PEER_TO_PEER_NODETYPE: LANInfo\nod = "Peer To Peer"
			Case #MIXED_NODETYPE: LANInfo\nod = "Mixed"
			Case #HYBRID_NODETYPE: LANInfo\nod = "Hybrid"
			Default: LANInfo\nod = "Unknown " + Str(\NodeType)
		EndSelect
		LANInfo\ScopeID = ReplaceString(PeekS(@\ScopeId[0],-1,#PB_Ascii), Chr(0), "")
		If \EnableProxy = 1: LANInfo\ProxyE = "Yes": Else: LANInfo\ProxyE = "No": EndIf
		If \EnableRouting = 1:  LANInfo\RoutE = "Yes": Else: LANInfo\RoutE = "No": EndIf
	EndWith
	Next

For i = 0 To CardsFound-1
	With IP_ADAPTER_INFO(i)
		Select \Type
			Case #MIB_IF_TYPE_OTHER: LANInfo\Type[i] = "Other"
			Case #MIB_IF_TYPE_ETHERNET: LANInfo\Type[i] = "Ethernet"
			Case #MIB_IF_TYPE_TOKENRING: LANInfo\Type[i] = "Tokenring"
			Case #MIB_IF_TYPE_FDDI: LANInfo\Type[i] = "FDDI"
			Case #MIB_IF_TYPE_PPP: LANInfo\Type[i] = "PPP"
			Case #MIB_IF_TYPE_LOOPBACK: LANInfo\Type[i] = "Loopback"
			Case #MIB_IF_TYPE_SLIP: LANInfo\Type[i] = "Slip"
			Default: LANInfo\Type[i] = "Unknown " + Str(\Type)
		EndSelect
		For ii = 0 To GetIfTables-1
			If PeekS(@If_entry(ii)\Description,-1,#PB_Unicode) = LANInfo\AdapterName[i]
				tmp2 = int32_uint32(If_entry(ii)\TransmitLinkSpeed): tmp = " bit"
				If tmp2 >= 1000:  tmp2 = tmp2 / 1000: tmp = " Kbit": EndIf
				If tmp2 >= 1000:  tmp2 = tmp2 / 1000: tmp = " Mbit": EndIf
				If tmp2 >= 1000:  tmp2 = tmp2 / 1000: tmp = " Gbit": EndIf
				LANInfo\Speed[i] = c2str(tmp2,2) + tmp
				LANInfo\sMTU[i] = Str(If_entry(ii)\Mtu) + " bytes"
				LANInfo\packsS[i] = FormatByteSize(If_entry(ii)\OutNUcastPkts + If_entry(ii)\OutUcastPkts)
				
				tmp = FormatByteSize(If_entry(ii)\OutOctets)
				If tmp = "":  tmp = "0": EndIf
				If If_entry(ii)\OutOctets > 1024
					tmp + "  ( " + SpaceDivider(If_entry(ii)\OutOctets) + " )"
					If Right(tmp,6) = GroupDemicals + "000 )":tmp=Left(tmp,Len(tmp)-6) + " )": EndIf
				EndIf
				LANInfo\bytesS[i] = tmp
				LANInfo\packsR[i] = FormatByteSize(If_entry(ii)\InNUcastPkts + If_entry(ii)\InUcastPkts)
				
				tmp = FormatByteSize(If_entry(ii)\InOctets)
				If tmp = "":  tmp = "0": EndIf
				If (If_entry(ii)\InOctets) > 1024
					tmp + "  ( " + SpaceDivider(If_entry(ii)\InOctets) + " )"
					If Right(tmp,6) = GroupDemicals + "000 )":tmp=Left(tmp,Len(tmp)-6) + " )": EndIf
				EndIf
				LANInfo\bytesR[i] = tmp
				
				If OSVersion() >= #PB_OS_Windows_Vista; data came from GetIfTable2_()
					Select If_entry(ii)\OperStatus
						Case 1: LANInfo\status[i] = "Operational"
						Case 2: LANInfo\status[i] = "Disconnected"
						Case 3: LANInfo\status[i] = "Testing"
						Case 4: LANInfo\status[i] = "Unknown"
						Case 5: LANInfo\status[i] = "Waiting to become operational"
						Case 6: LANInfo\status[i] = "Disconnected - Some component is not present"
						Case 7: LANInfo\status[i] = "Disconnected - one or more of lower-layer interfaces are down"
						Default: LANInfo\status[i] = "Unknown " + c2str(int32_uint32(If_entry(ii)\OperStatus),0)
					EndSelect
				Else; data came from GetIfTable_()
					Select If_entry(ii)\OperStatus
						Case #MIB_IF_OPER_STATUS_NON_OPERATIONAL: LANInfo\status[i] = "Non operational"
						Case #MIB_IF_OPER_STATUS_UNREACHABLE: LANInfo\status[i] = "Unreachable"
						Case #MIB_IF_OPER_STATUS_DISCONNECTED: LANInfo\status[i] = "Disconnected"
						Case #MIB_IF_OPER_STATUS_CONNECTING: LANInfo\status[i] = "Connecting"
						Case #MIB_IF_OPER_STATUS_CONNECTED: LANInfo\status[i] = "Connected"
						Case #MIB_IF_OPER_STATUS_OPERATIONAL: LANInfo\status[i] = "Operational"
						Default: LANInfo\status[i] = "Unknown " + c2str(int32_uint32(If_entry(ii)\OperStatus),0)
					EndSelect 	
				EndIf
				If OSVersion() >= #PB_OS_Windows_Vista; data came from GetIfTable2_()
					If If_entry(ii)\InterfaceAndOperStatusFlags & 1 = 1
						LANInfo\HWInterface[i] = "Yes"
					Else
						LANInfo\HWInterface[i] = "No"
					EndIf
					
					If (If_entry(ii)\InterfaceAndOperStatusFlags >> 1) & 1 = 1 
						LANInfo\FilterInterface[i] = "Yes"
					Else
						LANInfo\FilterInterface[i] = "No"
					EndIf
					;Debug (If_entry(ii)\InterfaceAndOperStatusFlags >> 2) & 1
					If (If_entry(ii)\InterfaceAndOperStatusFlags >> 2) & 1 = 1
						LANInfo\HasConntectorPresent[i] = "Yes"
					Else
						LANInfo\HasConntectorPresent[i] = "No"
					EndIf
					
					If (If_entry(ii)\InterfaceAndOperStatusFlags >> 3) & 1 = 1
						LANInfo\PortAuthenticated[i] = "No"
					Else
						LANInfo\PortAuthenticated[i] = "Yes"
					EndIf
					
					If (If_entry(ii)\InterfaceAndOperStatusFlags >> 4) & 1 = 1
						LANInfo\MediaConnected[i] = "No"
					Else
						LANInfo\MediaConnected[i] = "Yes"
						If If_entry(ii)\MediaConnectState = 1
							LANInfo\MediaConnected[i] + " (connector is plugged in)"
						ElseIf If_entry(ii)\MediaConnectState = 2
							LANInfo\MediaConnected[i] + " (connector is not plugged in)"
						EndIf
					EndIf
					
					If (If_entry(ii)\InterfaceAndOperStatusFlags >> 5) & 1 = 1
						LANInfo\Paused[i] = "Yes"
					Else
						LANInfo\Paused[i] = "No"
					EndIf
					
					If (If_entry(ii)\InterfaceAndOperStatusFlags >> 6) & 1 = 1
						LANInfo\LowPower[i] = "Yes"
					Else
						LANInfo\LowPower[i] = "No"
					EndIf
					
					If (If_entry(ii)\InterfaceAndOperStatusFlags >> 7) & 1 = 1
						LANInfo\EndPoint[i] = "Yes"
					Else
						LANInfo\EndPoint[i] = "No"
					EndIf
				EndIf
				Break
			EndIf
		Next	
		LANInfo\IPAddr[i] = PeekS(@\IpAddressList\IpAddress,-1,#PB_Ascii)
		LANInfo\SubMask[i] = PeekS(@\IpAddressList\IpMask,-1,#PB_Ascii)
		tmp = ""
		If Len(PeekS(@\AdapterName,-1,#PB_Ascii)) >= \AddressLength
			For lIncrement.l = 0 To \AddressLength-1
				tmp = tmp + RSet(Hex(\Address[lIncrement] & $FF),2,"0")
			Next lIncrement
			tmp = RSet(tmp,12,"0")
			tmp = Left(tmp, 2) + ":" + Mid(tmp, 3, 2) + ":" + Mid(tmp, 5, 2) + ":" + Mid(tmp, 7, 2) + ":" + Mid(tmp, 9, 2) + ":" + Mid(tmp, 11, 2)
			LANInfo\Addr[i] = tmp
		EndIf
		LANInfo\Indx[i] = (c2str(int32_uint32(\Index),0))
		
		If \DhcpEnabled = 1:  LANInfo\DHCPE[i] = "Yes": Else: LANInfo\DHCPE[i] = "No": EndIf
		LANInfo\DHCPIPAddr[i] = PeekS(@\DhcpServer\IpAddress,-1,#PB_Ascii)
		LANInfo\DHCPIPMask[i] = PeekS(@\DhcpServer\IpMask,-1,#PB_Ascii)
		If \LeaseObtained > 10000 
			tmp = FormatDate("%dd/%mm/%yyyy , %hh:%ii:%ss",AddDate( 1/1/1970,#PB_Date_Second, \LeaseObtained))
			LANInfo\DHCPLObt[i] = FormatDate("%dd/%mm/%yyyy , %hh:%ii:%ss",AddDate( ParseDate("%dd/%mm/%yyyy , %hh:%ii:%ss",tmp),#PB_Date_Minute,-TZResult ))
		Else
		LANInfo\DHCPLObt[i] = "NotAvailable"
		EndIf
		If \LeaseExpires > 10000 
			tmp = FormatDate("%dd/%mm/%yyyy , %hh:%ii:%ss",AddDate( 1/1/1970,#PB_Date_Second, \LeaseExpires))
			LANInfo\DHCPLExp[i] = FormatDate("%dd/%mm/%yyyy , %hh:%ii:%ss",AddDate( ParseDate("%dd/%mm/%yyyy , %hh:%ii:%ss",tmp),#PB_Date_Minute,-TZResult))
		Else
			LANInfo\DHCPLExp[i] = "NotAvailable"
		EndIf
		
		CopyMemory(@\IpAddressList,@IP_ADDR_STRING,SizeOf(IP_ADDR_STRING1))
		For ii=0 To 100
			If IP_ADDR_STRING\NextAdapter <> 0 
				If IsBadReadPtr_(@IP_ADDR_STRING\NextAdapter, SizeOf(IP_ADDR_STRING1)) = #False 
					MoveMemory(@IP_ADDR_STRING\NextAdapter, @IP_ADDR_STRING, SizeOf(IP_ADDR_STRING1))
				EndIf
			Else
				Break
			EndIf
		Next
		LANInfo\GateIPAddress[i] = PeekS(@\GatewayList\IpAddress,-1,#PB_Ascii)
		LANInfo\GateIPMask[i] = PeekS(@\GatewayList\IpMask,-1,#PB_Ascii)
		If \HaveWINS = 1:  LANInfo\HaveWINS[i] = "Yes": Else: LANInfo\HaveWINS[i] = "No": EndIf
		LANInfo\PWINSIPAddress[i] = PeekS(@\PrimaryWinsServer\IpAddress,-1,#PB_Ascii)
		LANInfo\PWINSIPMask[i] = PeekS(@\PrimaryWinsServer\IpMask,-1,#PB_Ascii)
		LANInfo\SWINSIPAddress[i] = PeekS(@\SecondaryWinsServer\IpAddress,-1,#PB_Ascii)
		LANInfo\SWINSIPMask[i] = PeekS(@\SecondaryWinsServer\IpMask,-1,#PB_Ascii)
	EndWith
Next
EndProcedure

If OpenWindow(0, 0, 0, 542, 510, "LAN", #PB_Window_SystemMenu | #PB_Window_ScreenCentered| #PB_Window_MinimizeGadget)
 		ListIconGadget(0,5,5,532,500,"Element",200,#PB_ListIcon_GridLines | #PB_ListIcon_FullRowSelect)
 		AddGadgetColumn(0,1,"Data",310)
EndIf

LAN()
AddGadgetItem(0,-1,"Host  name"+Chr(10)+LANInfo\HostName)
AddGadgetItem(0,-1,"Domain  name"+Chr(10)+LANInfo\DomainName)
AddGadgetItem(0,-1,"DNS  enabled"+Chr(10)+LANInfo\DNSE)
For i=0 To 10
	If LANInfo\DNSIPAdd[i] <> ""
		AddGadgetItem(0,-1,"DNS  Server  IP  address  #" + Str(i+1)+Chr(10)+LANInfo\DNSIPAdd[i])
	EndIf
Next
AddGadgetItem(0,-1,"Node  type"+Chr(10)+LANInfo\nod)
AddGadgetItem(0,-1,"Scope  ID"+Chr(10)+LANInfo\ScopeID)
AddGadgetItem(0,-1,"WINS  Proxy  Enabled"+Chr(10)+LANInfo\ProxyE)
AddGadgetItem(0,-1,"IP  Routing  Enabled"+Chr(10)+LANInfo\RoutE)
For i=0 To 10
	If LANInfo\AdapterName[i] <> ""
		AddGadgetItem(0,-1,""+Chr(10)+"")
		AddGadgetItem(0,-1,"Connection  #"+Str(i+1)+Chr(10)+"")
		SetGadgetItemColor(0,CountGadgetItems(0)-1,#PB_Gadget_FrontColor,$906000,0)
		AddGadgetItem(0,-1,"Adapter  name"+Chr(10)+LANInfo\AdapterName[i])
		AddGadgetItem(0,-1,"Type"+Chr(10)+LANInfo\Type[i])
		AddGadgetItem(0,-1,"Speed"+Chr(10)+LANInfo\Speed[i])
		AddGadgetItem(0,-1,"Maximum  Transfer  Unit  Size  (MTU)"+Chr(10)+LANInfo\sMTU[i])
		AddGadgetItem(0,-1,"Packets  sent"+Chr(10)+LANInfo\packsS[i])
		AddGadgetItem(0,-1,"Bytes  sent"+Chr(10)+LANInfo\bytesS[i])
		AddGadgetItem(0,-1,"Packets  received"+Chr(10)+LANInfo\packsR[i])
		AddGadgetItem(0,-1,"Bytes  received"+Chr(10)+LANInfo\bytesR[i])
		AddGadgetItem(0,-1,"Status"+Chr(10)+LANInfo\status[i])
		AddGadgetItem(0,-1,"IP"+Chr(10)+LANInfo\IPAddr[i])
		AddGadgetItem(0,-1,"SubMask"+Chr(10)+LANInfo\SubMask[i])
		AddGadgetItem(0,-1,"Address"+Chr(10)+LANInfo\Addr[i])
		AddGadgetItem(0,-1,"Index"+Chr(10)+LANInfo\Indx[i])
		AddGadgetItem(0,-1,"DHCP  enabled"+Chr(10)+LANInfo\DHCPE[i])
		AddGadgetItem(0,-1,"DCHP  IP  address"+Chr(10)+LANInfo\DHCPIPAddr[i])
		AddGadgetItem(0,-1,"DCHP  IP  mask"+Chr(10)+LANInfo\DHCPIPMask[i])
		AddGadgetItem(0,-1,"DHCP lease obtained"+Chr(10)+LANInfo\DHCPLObt[i])
		AddGadgetItem(0,-1,"DHCP lease expires"+Chr(10)+LANInfo\DHCPLExp[i])
		AddGadgetItem(0,-1,"Gateway  IP  address"+Chr(10)+LANInfo\GateIPAddress[i])
		AddGadgetItem(0,-1,"Gateway  IP  mask"+Chr(10)+LANInfo\GateIPMask[i])
		AddGadgetItem(0,-1,"Have  WINS"+Chr(10)+LANInfo\HaveWINS[i])
		If LANInfo\HaveWINS[i] = "Yes"
			AddGadgetItem(0,-1,"Primary  WINS  Server  IP  address"+Chr(10)+LANInfo\PWINSIPAddress[i])
			AddGadgetItem(0,-1,"Primary  WINS  Server  IP  mask"+Chr(10)+LANInfo\PWINSIPMask[i])
			AddGadgetItem(0,-1,"Secondary  WINS  Server  IP  address"+Chr(10)+LANInfo\SWINSIPAddress[i])
			AddGadgetItem(0,-1,"Secondary  WINS  Server  IP  Mask"+Chr(10)+LANInfo\SWINSIPMask[i])
		EndIf
		If OSVersion() >= #PB_OS_Windows_Vista
			AddGadgetItem(0,-1,"Is a hardware interface"+Chr(10)+LANInfo\HWInterface[i])
			AddGadgetItem(0,-1,"Is a filter interface"+Chr(10)+LANInfo\FilterInterface[i])
			AddGadgetItem(0,-1,"Has a connector present"+Chr(10)+LANInfo\HasConntectorPresent[i])
			AddGadgetItem(0,-1,"Is port authenticated"+Chr(10)+LANInfo\PortAuthenticated[i])
			AddGadgetItem(0,-1,"Is media connected"+Chr(10)+LANInfo\MediaConnected[i])
			AddGadgetItem(0,-1,"Is paused"+Chr(10)+LANInfo\Paused[i])
			AddGadgetItem(0,-1,"Is at low power"+Chr(10)+LANInfo\LowPower[i])
			AddGadgetItem(0,-1,"Is an End-Point device"+Chr(10)+LANInfo\EndPoint[i])
		EndIf
	EndIf
Next
	
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow

End   

Re: LAN info - Windows only

Posted: Tue Sep 09, 2014 8:38 pm
by falsam
Thank doctorized :)

Re: LAN info - Windows only

Posted: Thu Nov 24, 2016 8:42 am
by SadStar
Dear Sirs.
All above codes are essentially wrong though work in some special cases.
Namely - when on each adapter only one IP address.

Please watch attentively structure declaration
https://msdn.microsoft.com/en-us/librar ... s.85).aspx
---------------------------
Namely -
"IpAddressList
Type: IP_ADDR_STRING
The list of IPv4 addresses associated with this adapter represented as a linked list of IP_ADDR_STRING structures. An adapter can have multiple IPv4 addresses assigned to it."
--------------------------
that is, the data received from GetAdaptersInfo_ () should not be treated as an array because they have a variable size.


Excuse me for my English - I used translation software

Re: LAN info - Windows only

Posted: Sat Dec 03, 2016 11:44 am
by doctorized
SadStar wrote:Dear Sirs.
All above codes are essentially wrong though work in some special cases.
Namely - when on each adapter only one IP address.

Please watch attentively structure declaration
https://msdn.microsoft.com/en-us/librar ... s.85).aspx
---------------------------
Namely -
"IpAddressList
Type: IP_ADDR_STRING
The list of IPv4 addresses associated with this adapter represented as a linked list of IP_ADDR_STRING structures. An adapter can have multiple IPv4 addresses assigned to it."
--------------------------
that is, the data received from GetAdaptersInfo_ () should not be treated as an array because they have a variable size.


Excuse me for my English - I used translation software
Seems you are right. You found the problem because, obviously, you have an adapter with multiple ip addresses. Can you do a test?
in "Structure IP_ADDR_STRING1" change

Code: Select all

NextAdapter.i
to

Code: Select all

NextAdapter.IP_ADDR_STRING1
and use a new IP_ADDR_STRING1 variable to get the new structure for every ip.