Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Buscar Temas de Hoy Marcar Foros Como Leídos

Coloboración Paypal con ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #15  
Antiguo 09-10-2013
Avatar de cesarsoftware
cesarsoftware cesarsoftware is offline
Miembro
 
Registrado: nov 2006
Posts: 241
Poder: 20
cesarsoftware Va por buen camino
Buenos días Nelson.

Implemente la función ChangeCodePage de forma que si al objeto TServidorSocket de le indica un codepage entonces la usa,
Código Delphi [-]
function TServidorSocket.Envia(cadena: ansistring): integer;
var
  size: word;
  Resultado, sendlen: integer;
  cadena437: ansistring;
begin
  Resultado := 0;
  if CodePage = 0 then
    cadena437 := cadena
  else
    cadena437 := ChangeCodePage(cadena, 437);
  size := Length(cadena437);
  if size = 0 then
  begin
    Result := -8;
    Exit;
  end;
  sendlen := Send(nSocket, cadena437[1], size, 0);
  if (sendlen = SOCKET_ERROR) or (sendlen < size) then
  begin
    case WSAGetLastError of
      WSANOTINITIALISED: ErrorString := 'A successful WSAStartup call must occur before using this function.';
      WSAENETDOWN: ErrorString := 'The network subsystem has failed.';
      WSAEACCES: ErrorString := 'The requested address is a broadcast address, but the appropriate flag was not set. Call setsockopt with the SO_BROADCAST socket option to enable use of the broadcast address.';
      WSAEINTR: ErrorString := 'A blocking Windows Sockets 1.1 call was canceled through WSACancelBlockingCall.';
      WSAEINPROGRESS: ErrorString := 'A blocking Windows Sockets 1.1 call is in progress, or the service provider is still processing a callback function.';
      WSAEFAULT: ErrorString := 'The buf parameter is not completely contained in a valid part of the user address space.';
      WSAENETRESET: ErrorString := 'The connection has been broken due to the keep-alive activity detecting a failure while the operation was in progress.';
      WSAENOBUFS: ErrorString := 'No buffer space is available.';
      WSAENOTCONN: ErrorString := 'The socket is not connected.';
      WSAENOTSOCK: ErrorString := 'The descriptor is not a socket.';
      WSAEOPNOTSUPP: ErrorString := 'MSG_OOB was specified, but the socket is not stream-style such as type SOCK_STREAM, OOB data is not supported in the communication domain associated with this socket, or the socket is unidirectional and supports only receive operations.';
      WSAESHUTDOWN: ErrorString := 'The socket has been shut down; it is not possible to send on a socket after shutdown has been invoked with how set to SD_SEND or SD_BOTH.';
      WSAEWOULDBLOCK: ErrorString := 'The socket is marked as nonblocking and the requested operation would block.';
      WSAEMSGSIZE: ErrorString := 'The socket is message oriented, and the message is larger than the maximum supported by the underlying transport.';
      WSAEHOSTUNREACH: ErrorString := 'The remote host cannot be reached from this host at this time.';
      WSAEINVAL: ErrorString := 'The socket has not been bound with bind, or an unknown flag was specified, or MSG_OOB was specified for a socket with SO_OOBINLINE enabled.';
      WSAECONNABORTED: ErrorString := 'The virtual circuit was terminated due to a time-out or other failure. The application should close the socket as it is no longer usable.';
      WSAECONNRESET: ErrorString := 'The virtual circuit was reset by the remote side executing a hard or abortive close. For UDP sockets, the remote host was unable to deliver a previously sent UDP datagram and responded with a "Port Unreachable" ICMP packet.';// The application should close the socket as it is no longer usable.';
      WSAETIMEDOUT: ErrorString := 'The connection has been dropped, because of a network failure or because the system on the other end went down without notice.';
    else
      ErrorString := 'Error Desconocido';
    end;
    Resultado := -9;
    Finaliza();
  end;
  Result := Resultado;
end;
Y lo curioso es que en la aplicación que me hacia falta funciono Gracias.
Pero al ser un objeto que uso en otras aplicaciones, probar en otra con algunos mensajes como "Máquina no encontrada" y no funciona

¿Se puede especificar un codepage para toda la aplicación? He visto en propiedades del proyecto "Compiling" y "Resource compiling" el valor para codepage, he puesto en ambos casos 437 y no noto diferencia, también está la opción "Version info" la posiblididad de definir el "Locale ID" pero tampoco veo resultado.

Asi que de momento mejor que antes ya estoy. Gracias.
__________________
Disfruta de la vida ahora, vas a estar muerto mucho tiempo.
Responder Con Cita
 


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
insert ansistring? noelr Conexión con bases de datos 0 23-11-2011 02:00:59
Uso de AnsiString 11_8_88 C++ Builder 8 14-08-2010 20:53:47
Generar un string con codigos ascii JordiP Varios 9 16-12-2009 11:39:16
string o AnsiString? javier20 OOP 1 19-08-2007 01:58:35
AnsiString en una Dll Trigger API de Windows 2 21-01-2004 22:53:20


La franja horaria es GMT +2. Ahora son las 14:46:08.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi