Код: Выделить всё
var
Bm: TMemoryStream;
bmp: TBitmap;
DC: HDC;
...
begin
bm := TMemoryStream.Create;
bmp:=TBitmap.Create;
bmp.Height:=Screen.Height;
bmp.Width:=Screen.Width;
DC:=GetDC(0);
bitblt(bmp.Canvas.Handle, 0, 0, Screen.Width, Screen.Height,
DC, 0, 0, SRCCOPY);
bmp.SaveToStream(bm);
ReleaseDC(0, DC);
end;
ServerSocket1.Socket.SendStream(bm);
И вот загвоздка, не знаю как получить это у клиента. Что писать на OnRead у ClientSocket? Нужно чтоб сформировался такой же Stream, который я загружу Image1.Picture.bitmap.loadfromstream();
Нашел такой вот код:
Код: Выделить всё
var
Stream : TWinSocketStream;
Buffer : array[0 .. 9] of Char;
...
while Socket.Connected do
begin
try
Stream := TWinSocketStream.Create(Socket, 60000);
try
FillChar(Buffer, 10, 0); { initialize the buffer }
{ give the client 60 seconds to start writing }
if Stream.WaitForData(60000) then
begin
if Stream.Read(Buffer, 10) = 0 then { if can’t read in 60 seconds }
Socket.Close; { close the connection }
{ now process the request }
end
else
Socket.Close; { if client doesn’t start, close }
finally
Stream.Free;
end;
except
end;
end;
