Ir para conteúdo
Fórum Script Brasil
  • 0

Enviar arquivo via Sockets por Delphi 2009 0u 2010


xlayx

Pergunta

Olá pessoal,estou tentando criar uma conexão remota para efetuar Printscreen.

já tenho um código todo feito que achei na net, porem ele funciona somente compilando no delphi 7,

ele compila de boa no delphi2010,sem dar nenhum erro... mas não transferi o arquivo jpeg ao executar e enviar o sendtext.

alguém pode mim da um help para funcionar corretamente no delphi 2010?? :wacko:

Siga abaixo código

Site com a fonte: http://www.forum-invaders.com.br/vb/showth...ados-via-socket

Código que transferi o arquivo

procedure TForm1.ClientSocket1Read(Sender: TObject; Socket: TCustomWinSocket);

var

s: string;

begin

s:=Socket.ReceiveText;

if not Receiving then

begin

if pos(#0,s) > 0 then

stSize:=strtoint(copy(s,1,pos(#0,s)-1))

else

exit;

Stream:=TMemoryStream.Create;

Receiving:=True;

delete(s,1,pos(#0,s));

end;

try

Stream.Write(s[1],length(s));

if Stream.Size = stSize then

begin

Stream.Position:=0;

Receiving:=False;

jpg:=TJPEGImage.Create;

jpg.LoadFromStream(Stream);

Image1.Picture.Assign(jpg);

Stream.Free;

end;

except

Stream.Free;

end;

end;

Link para o comentário
Compartilhar em outros sites

12 respostass a esta questão

Posts Recomendados

  • 0

veja se voce declarou a uses ScktComp.

TCustomWinSocket is the base class for all Windows socket objects.

Unit

ScktComp

Description

TCustomWinSocket introduces properties, events, and methods to describe an endpoint in a Windows socket connection. Descendants of TCustomWinSocket are used by socket components to manage the Windows socket API calls and to store information about a socket communication link.

A Windows socket encapsulates a set of communication protocols to allow the application to connect to other machines for reading or writing information. Windows sockets provide connections based on the TCP/IP protocol. They also allow connections that use the Xerox Network System (XNS), Digital’s DECnet protocol, or Novell’s IPX/SPX family. Sockets allow an application to form connections to other machines without being concerned with the details of the actual networking software.

Descendants of TCustomWinSocket represent different endpoints in socket connections. TClientWinSocket represents the client endpoint of a socket communication link to a server socket. TServerWinSocket represents the server endpoint of a listening connection. TServerClientWinSocket represents the server endpoint of a socket communication link to a client socket.

abraço

Link para o comentário
Compartilhar em outros sites

  • 0

já baixei varios da internet para transferir arquivo ou imagem via socket e nenhum funcioona compilando via delphi 2010.

ele compila de boas sem dar errros no delphi 2010, mas porem a parte de transferir a imagem não funciona.

alguém mim da um help awe ou tem a fonte ou o conhecimento de como fazer funcionar no delphi 2010?porque já tentei de tudo e não consigo..

obrigado gente

Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,2k
    • Posts
      651,9k
×
×
  • Criar Novo...