Recent

Author Topic: [Help] Using Indy to send screencast  (Read 291 times)

Nolan

  • New member
  • *
  • Posts: 8
[Help] Using Indy to send screencast
« on: August 05, 2019, 10:47:43 am »
Using Indy i have been able to implememnt client and server and i did like the topic well than using Raw winsock , Indy did help me, but I do have one issue i want to trade out.
I am coding something like my own teamviewer which requires client and server now i want to get the screenshot from the server and send to client, i am trying to implement something like RFB here using simple indy sockets and dimensions , just want to know what i am not doing very correctly.

Looks like this

Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormCreate(Sender: TObject);
  2. begin
  3. IdTCPServer1:=TIdTCPServer.Create(nil);
  4. IdTCPServer1.DefaultPort:=50000;
  5. IdTCPServer1.OnExecute:=IdTCPServer1Execute;
  6. IdTCPServer1.Active:=true;
  7. end;

Now the onExecute would look like this to grab the screenshot and send vis Indy (Winsock)

Code: Pascal  [Select][+][-]
  1. procedure TForm1.IdTCPServer1Execute(AContext: TIdContext);
  2. var
  3. mem_dc : HDC;
  4. bmp : TBitmap;
  5. _bm : BITMAP;
  6. w, h : Integer;
  7. dimensions : Integer;
  8. begin
  9.         bmp := TBitmap.Create;
  10.         GetObject (bm, sizeof (BITMAP), @_bm);
  11.         w := _bm.bmWidth;
  12.         h := _bm.bmHeight;
  13.         bmp.Height := h;
  14.         bmp.Width := w;
  15.         mem_dc := CreateCompatibleDC (bmp.Canvas.Handle);
  16.         SelectObject (mem_dc, bm);
  17.         BitBlt (bmp.Canvas.Handle,0, 0, w, h, mem_dc, 0, 0, SRCCOPY);
  18.         Canvas.Draw (0, 0, bmp);
  19.         DeleteObject (mem_dc);
  20.         bmp.Free;
  21.        
  22.         //Send Dimensions vis Indy here
  23.         dimensions := w * h;
  24.         while True do
  25.         begin
  26.                 AContext.Connection.IOHandler.WriteLn(dimensions);
  27.                 // and do same for Pixels
  28.         end;
  29. end.

I have some small issue here as i seem to have something missing, i do want to know if there is something i am actually missing as to sending an infinite loop screen am i on the correct track here?

 

TinyPortal © 2005-2018