Ignore:
Timestamp:
Feb 11, 2008, 11:18:05 AM (16 years ago)
Author:
george
Message:

Opraveno: Načítání seznamu síťových adaptérů přes API funkce.
Opraveno: Uvolňění paměti AppUserEventsOptions.
Přidáno: Textová identifikace Windows Vista.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SunriseChatNetworkCoreUnit.pas

    r9 r11  
    77  Forms, StdCtrls, ExtCtrls, SunriseChatCoreUtils, DateUtils, SunriseChatCoreUnit,
    88  cWindows, cSockets, cSocketsUDP, cTCPClient, cTCPServer, cUtils, WinSock,
    9   cWinSock, Registry;
     9  cWinSock, Registry, UEthernetAddress;
    1010
    1111const
     
    192192var
    193193  I, II: Integer;
    194   PnpInstanceID: string;
    195   Buf: string;
     194  Status: Cardinal;
     195  AdaptersList : array of IP_ADAPTER_INFO;
     196  BufSize: Cardinal;
    196197  IPParts: TArrayOfString;
    197198  SubnetParts: TArrayOfString;
    198199  NewNetworkInterface: TNetworkInterface;
    199   Status: Cardinal;
    200   AdaptersList : array of IP_ADAPTER_INFO;
    201   BufSize: Cardinal;
    202 begin
    203   // Clear list
    204   for I := 0 to NetworkInterfaces.Count-1 do
     200
     201function IpListToStr(pIpAddr : PIP_ADDR_STRING) : String;
     202begin
     203  Result := '';
     204  repeat
     205    Result := Result + ', ' + Pchar(Addr(pIpAddr^.IpAddress));
     206    pIpAddr := pIpAddr.Next;
     207  until pIpAddr = nil;
     208  Delete(Result, 1, 2);
     209  if Result = '' then Result := 'none';
     210end;
     211
     212begin
     213  for I := 0 to NetworkInterfaces.Count - 1 do
    205214    TNetworkInterface(NetworkInterfaces[I]).Free;
    206215  NetworkInterfaces.Clear;
     216
    207217  if Win32Platform > 1 then begin
     218    // Windows NT/2000/XP/Vista
    208219    BufSize := 0;
    209220    Status := GetAdaptersInfo(@AdaptersList[0], BufSize);
     
    213224      NewNetworkInterface := TNetworkInterface.Create(Self);
    214225      with NewNetworkInterface do begin
    215 //      IPAddress := CurrentIpAddress^.IpAddress.s;
    216 //      SubNetMask := CurrentIpAddress^.IpMask.s;
    217226        IPAddress := IpAddressList.IPAddress.S;
    218227        SubNetMask := IpAddressList.IPMask.s;
    219228        GUID := AdapterName;
    220 (*
    221       II := MAX_ADAPTER_DESCRIPTION_LENGTH;
    222       while Description[II] = #0 do Dec(II);
    223       SetLength(Name, II);
    224       Move(Description[0], Name[1], Length(Name));
    225 *)
    226229        Name := Description;
    227230        SubnetParts := Explode('.', SubNetMask);
     
    233236      NetworkInterfaces.Add(NewNetworkInterface);
    234237    end;
    235  end else begin
    236     // For Windows 9x compatibility
     238  end else begin
     239    // Windows 95/98/Me
    237240    for I := 0 to High(LocalIPAddressesStr) do begin
    238241      NewNetworkInterface := TNetworkInterface.Create(Self);
Note: See TracChangeset for help on using the changeset viewer.