Recent

Author Topic: Indy WSAStartup Error  (Read 8851 times)

SONFEDAI

  • Jr. Member
  • **
  • Posts: 55
Indy WSAStartup Error
« on: December 11, 2011, 10:05:49 pm »
Indy can not Start Winsock on Windows CE.

Error is "Error on call to Winsock2 library function WSAStartup"

How to solve this problem.

Any Idea?
I'm using
   Lazarus: 0.9.3.1
   Date: 2011-11-05
   FPC: 2.5.1
   SVN Ver.: 29060

SONFEDAI

  • Jr. Member
  • **
  • Posts: 55
Re: Indy WSAStartup Error
« Reply #1 on: December 12, 2011, 12:04:04 am »
Solved

Thanks

I'm using
   Lazarus: 0.9.3.1
   Date: 2011-11-05
   FPC: 2.5.1
   SVN Ver.: 29060

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: Indy WSAStartup Error
« Reply #2 on: December 12, 2011, 07:31:37 am »
Please always mention how you solved something so that people searching in the future can use this information. thanks

SONFEDAI

  • Jr. Member
  • **
  • Posts: 55
Re: Indy WSAStartup Error
« Reply #3 on: December 13, 2011, 08:26:33 pm »
Original Indy 10.2.0.3 IdWinsock2.Pas

Quote
function FixupStub(hDll: THandle; const AName: string): Pointer;
{$IFDEF USEINLINE}inline;{$ENDIF}
begin
  if hDll = 0 then begin
    raise EIdWinsockStubError.Build(WSANOTINITIALISED, RSWinsockCallError, [AName]);
  end;
  Result := Windows.GetProcAddress(hDll, {$IFDEF WINCE}PWideChar {$ELSE}PChar {$ENDIF}(AName));
  if Result = nil then begin
    raise EIdWinsockStubError.Build(WSAEINVAL, RSWinsockCallError, [AName]);
  end;
end;

Change It

Quote
function FixupStub(hDll: THandle; const AName: string): Pointer;
{$IFDEF USEINLINE}inline;{$ENDIF}
{$IFDEF WINCE}
Var
  S: Array[0..512] Of WideChar;
{$ENDIF}
begin
  if hDll = 0 then begin
    raise EIdWinsockStubError.Build(WSANOTINITIALISED, RSWinsockCallError, [AName]);
  end;
  {$IFDEF WINCE}
    StringToWideChar(AName, S, Length(AName) + 1);
    Result := Windows.GetProcAddress(hDll, S);
  {$ELSE}
    Result := Windows.GetProcAddress(hDll, PChar(AName));
  {$ENDIF}
  if Result = nil then begin
    raise EIdWinsockStubError.Build(WSAEINVAL, RSWinsockCallError, [AName]);
  end;
end;

I Think Lazarus For WinCE not convert (using cast) String to WideChar because result is AName is not correct in original code

But IdTCPClient do not connect

I'm working
I'm using
   Lazarus: 0.9.3.1
   Date: 2011-11-05
   FPC: 2.5.1
   SVN Ver.: 29060

 

TinyPortal © 2005-2018