



É necessário estar declarado WinSock na seção uses,
em versões unicode declare Winapi.WinSock.
A função retorna True se o WinSock estiver habilitado.
Segue o código fonte da função:
1 2 3 4 5 6 7 8 9 10 11 12 | function WinsockEnabled: Boolean; var wsaData : TWSAData; begin Result := True; case WSAStartup($0101, wsaData) of WSAEINVAL, WSASYSNOTREADY, WSAVERNOTSUPPORTED: Result := False; else Winsock.WSACleanup; end; end; |
Veja um exemplo de uso:
1 2 3 4 5 6 7 | procedure TForm1.Button1Click(Sender: TObject); begin if (WinsockEnabled) then ShowMessage('Winsock está habilidado.') else ShowMessage('Winsock NÃO está habilidado.'); end; |