Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Netzwerke (https://www.delphipraxis.net/14-netzwerke/)
-   -   Delphi Protokoll installiert? (WSAEnumProtocols) (https://www.delphipraxis.net/134177-protokoll-installiert-wsaenumprotocols.html)

CodeX 17. Mai 2009 00:52


Protokoll installiert? (WSAEnumProtocols)
 
Ich möchte gerne prüfen, ob das Ipv6 Protokoll installiert ist. Das sollte mit der Funktion WSAEnumProtocols aus Winsock2 möglich sein. Leider erhalte ich bei genau diesem Aufruf [LCount := WSAEnumProtocols(nil,LPInfo,LLen);] den Fehler "Access violation at address 00000000. Read of address 00000000." Warum? Muss noch irgendetwas initialisiert werden? Oder ganz anders? :gruebel:

Delphi-Quellcode:
function IPv6Installiert : Boolean;
var
  LLen : LongWord;
  LPInfo, LPCurPtr : LPWSAProtocol_Info;
  LCount : Integer;
  i : Integer;
begin
  Result := False;
  LLen := 0;
  WSAEnumProtocols(nil,nil,LLen);
  GetMem(LPInfo,LLen);

  try
    LCount := WSAEnumProtocols(nil,LPInfo,LLen);
    if LCount <> SOCKET_ERROR then
    begin
      LPCurPtr := LPInfo;
      for i := 0 to LCount-1 do
      begin
        Memo1.Lines.Add(IntToStr(LPCurPtr^.iAddressFamily));
        Result := (LPCurPtr^.iAddressFamily=PF_INET6);
        if Result then
        begin
          Break;
        end;
        Inc(LPCurPtr);
      end;
    end;
  finally
    FreeMem(LPInfo);
  end;
end;
edit: Falls von Belangen: WSAEnumProtocols kommt aus IdWinsock2 (Indy10).


Alle Zeitangaben in WEZ +1. Es ist jetzt 23:38 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz