...check if Winsock is enabled?

Author: Mike Carey

Category: Internet / LAN

uses
  
Winsock;

function WinsockEnabled: Boolean;
var
  
wsaData: TWSAData;
begin
  
Result := True;
  case Winsock.WSAStartup($0101, wsaData) of
    
WSAEINVAL, WSASYSNOTREADY, WSAVERNOTSUPPORTED: Result := False;
    else
      
Winsock.WSACleanup;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  if 
WinsockEnabled then
    
ShowMessage('Winsock is enabled')
  else
    
ShowMessage('Winsock is disabled');
end;

 

printed from
www.swissdelphicenter.ch
developers knowledge base