GetAdaptersInfo

Anfängerfragen zum Programmieren mit PureBasic.
Benutzeravatar
Andre
PureBasic Team
Beiträge: 1765
Registriert: 11.09.2004 16:35
Computerausstattung: MacBook Core2Duo mit MacOS 10.6.8
Lenovo Y50 i7 mit Windows 10
Wohnort: Saxony / Deutscheinsiedel
Kontaktdaten:

Beitrag von Andre »

ts-soft hat geschrieben:Im engl. wurde bestätigt, läuft fehlerfrei unter PB4. Hoffentlich braucht Andrè
den noch (ist ja auch im CodeArchiv) und findet ihn hier :mrgreen:
Hab grad den aktualisierten Code in der entsprechenden Source-Datei gespeichert. Danke!

Ansonsten verweise ich einfach nochmal auf meinen Hilfeaufruf: PB Codearchiv - Übersetzer gesucht (nach PB 4)
Bye,
...André
(PureBasicTeam::Docs - PureArea.net | Bestellen:: PureBasic | PureVisionXP)
Benutzeravatar
ts-soft
Beiträge: 22292
Registriert: 08.09.2004 00:57
Computerausstattung: Mainboard: MSI 970A-G43
CPU: AMD FX-6300 Six-Core Processor
GraKa: GeForce GTX 750 Ti, 2 GB
Memory: 16 GB DDR3-1600 - Dual Channel
Wohnort: Berlin

Beitrag von ts-soft »

@André
Ich wußte, das Du es finden würdest :wink:
Entweder hier oder im engl.
PureBasic 5.73 LTS | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Nutella hat nur sehr wenig Vitamine. Deswegen muss man davon relativ viel essen.
Bild
pws32
Beiträge: 52
Registriert: 27.09.2004 12:33

Beitrag von pws32 »

Hi,

habe im int. Forum noch einen Code entdeckt und etwas erweitert, läuft sogar stabil unter meinem Problemcomputer und ist sogar stabil mit der Aussage ob die IP statisch ist oder per DHCP bezogen wird

Code: Alles auswählen

; http://msdn.microsoft.com/library/default.asp?url=/library/en-us/iphlp/iphlp/getadaptersinfo.asp
; with the help of IPHlpAPI.inc from the Powerbasic include-file for the structures
; Microsoft isn´t quite a help here :-)

DHCPServerEnabled.s

Structure IP_ADDR_STRING
  pNext.l
  IpAddress.b[16]
  IpMask.b[16]
  Context.l
EndStructure

Structure IP_ADAPTER_INFO
Next.l
ComboIndex.l
AdapterName.b[260] ; MAX_ADAPTER_NAME_LENGTH + 4
Description.b[132] ; MAX_ADAPTER_DESCRIPTION_LENGTH + 4
AdressLength.l
Address.b[8] ; MAX_ADAPTER_ADDRESS_LENGTH
Index.l
Type.l
DhcpEnabled.l
CurrentIpAddressPTR.l
IpAddressList.IP_ADDR_STRING
GatewayList.IP_ADDR_STRING
DhcpServer.IP_ADDR_STRING
HaveWins.l
PrimaryWinsServer.IP_ADDR_STRING
SecondaryWinsServer.IP_ADDR_STRING
LeaseObtained.l
LeaseExpires.l
EndStructure

length.l=0
Result=GetAdaptersInfo_(0,@length) ; Get the length for Buffer
If Result=#ERROR_BUFFER_OVERFLOW
  *Buffer=AllocateMemory(length)
  Result=GetAdaptersInfo_(*Buffer,@length)
  If Result=#ERROR_SUCCESS
    adapters=length/SizeOf(IP_ADAPTER_INFO)
    For x=0 To adapters-1
      Debug "AdapterNr : "+Str(x+1)
      tempipinfo.IP_ADAPTER_INFO
      For i=0 To SizeOf(IP_ADAPTER_INFO)-1
        byte.b=PeekB(*Buffer+(x*640)+i)
        PokeB(tempipinfo+i,byte)
      Next
      Debug "Adapter : "+PeekS(@tempipinfo\Description)
      Debug "IP-Adress : "+PeekS(@tempipinfo\IpAddressList+4)
      Debug "Gateway : "+PeekS(@tempipinfo\GatewayList+4)
     
      Debug "P-Wins : "+PeekS(@tempipinfo\PrimaryWinsServer+4)
      Debug "S-Wins : "+PeekS(@tempipinfo\SecondaryWinsServer+4)
      
      
      ;Debug "DHCP-Server : "+PeekS(@tempipinfo\DhcpServer+4)
      If PeekS(@tempipinfo\DhcpServer+4) = "255.255.255.255"
        Debug "STATIC IP Configuration"
       Else
        Debug "DHCP Server Adress : " +PeekS(@tempipinfo\DhcpServer+4)
      EndIf
      
      
      mac$=""
      For i=0 To 5
        byte.b=PeekB(@tempipinfo\Address+i)
        If byte>=0
          mac$+RSet(Hex(byte),2,"0")
        Else
          mac$+RSet(Hex(byte+256),2,"0")
        EndIf
        If i<5
          mac$+":"
        EndIf
      Next
      Debug "MAC-Address "+mac$
    Next
  Else
    Debug "Error : "+Str(Result)
  EndIf
EndIf 
ich weis das ich nix weis
Antworten