WSAStartup returns error 10091

Giganews Newsgroups
Subject: WSAStartup returns error 10091
Posted by:  Dario (ddu…@tango04.net)
Date: Wed, 8 Aug 2007

Hi, i have created a Mail dll (that uses last version of indy components)
and i use it within 2 applications in one it works fine in the other
application in fails to load properly. I use D2006.

I have debugged it and the error is found here:

procedure InitializeWinSock;
var
  LData: TWSAData;
  LError: DWORD;
begin
  if hWinSockDll = 0 then
  begin
    hWinSockDll := Windows.LoadLibrary(WINSOCK2_DLL);
    if hWinSockDll <> 0 then
    begin
      LError := WSAStartup($202, LData);
      if LError = 0 then begin
        Exit;
      end;
      Windows.FreeLibrary(hWinSockDll);
      hWinSockDll := 0;
    end
    else
    begin
      LError := Windows.GetLastError;
    end;
    raise EIdWinsockStubError.Build(LError, RSWinsockLoadError,
[WINSOCK2_DLL]);
  end;
end;

This funcion is called from the initialization section of a file... so if it
raises an error the aplication cant even start.

Is there any way to fix the problem or does any1 know what can cause it?

Ty very much,
Dario Durà

Replies