Solved

Remote Screen

Posted on 2003-10-26
9
305 Views
Last Modified: 2010-04-05
Hello, I need a client and server program where you can see the desktop of where the server is running.
I need an example.

Thx Karamja

{ Note: I will give upto 735 points but dew to limit I can only put 500, I will give you the rest of the points in a diff question }
0
Comment
Question by:Karamja
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
9 Comments
 
LVL 2

Accepted Solution

by:
alsantos earned 500 total points
ID: 9622742
Hi Karamja, I think you can try this code and the file will be saved at c:\test.jpg

unit Unit1;

interface

uses
  Windows, Jpeg, Forms, Graphics, IdTCPServer, SysUtils, IdComponent,
  IdTCPConnection, IdTCPClient, IdBaseComponent, StdCtrls,
  Classes, Controls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    IdClient: TIdTCPClient;
    IdTCPServer1: TIdTCPServer;
    procedure Button1Click(Sender: TObject);
    procedure IdTCPServer1Execute(AThread: TIdPeerThread);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

function CaptureScreen: TJPEGImage;
var
  DC : HDC;
  ABitmap:TBitmap;
  Jpg: TJPEGImage;
begin
  DC := GetDC (GetDesktopWindow);
  ABitmap:=TBitmap.Create;
  try
    ABitmap.Width  := GetDeviceCaps (DC, HORZRES);
    ABitmap.Height := GetDeviceCaps (DC, VERTRES);
    BitBlt(ABitmap.Canvas.Handle, 0, 0, ABitmap.Width,
           ABitmap.Height,DC, 0, 0, SRCCOPY);
    Jpg := TJPEGImage.Create;
    with Jpg do
    begin
      PixelFormat := jf24Bit;
      Assign(ABitmap);
      Compress;
    end;
    Result := Jpg;
  finally
    ABitmap.Free;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  msSend: TMemoryStream;
  Jpeg: TJPEGImage;
begin
  idClient.Port:=9090;
  idClient.Host:='127.0.0.1';
  idTCpServer1.DefaultPort:=9090;
  idTcpServer1.Active:=True;
  idClient.Connect;
  Jpeg := CaptureScreen;
  msSend := TMemoryStream.Create;
  Jpeg.SaveToStream(msSend);
  if idClient.Connected then
  begin
    idClient.WriteLn(IntToStr(msSend.Size));
    idClient.WriteStream(msSend);
  end;
  msSend.Free;
  idClient.Disconnect;
end;


procedure TForm1.IdTCPServer1Execute(AThread: TIdPeerThread);
var
  mS: TMemoryStream;
  S: String;
begin
  with AThread.Connection do
  begin
    S := ReadLn;
    mS := TMemoryStream.Create;
    try
      ReadStream(mS, StrToInt(S));
      mS.SaveToFile('c:\test.jpg');
    finally
      mS.Free;
    end;
  end;
end;

end.

alsantos
0
 

Author Comment

by:Karamja
ID: 9622883
Hello, Can you upload this project for me to download
0
 
LVL 2

Expert Comment

by:alsantos
ID: 9622963
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Karamja
ID: 9622979
That url dont work? lol, Could you e-mail it to webmaster@express-hosting.co.uk
0
 

Author Comment

by:Karamja
ID: 9623076
Thx, Sorry about the uploading and e-mail stuff
0
 
LVL 2

Expert Comment

by:alsantos
ID: 9623085
Thanks too. :)

alsantos
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 9623294
hmm, there is a memory-leak i guess
-> the result of the captureScreen-function is never freed
0
 
LVL 2

Expert Comment

by:alsantos
ID: 9623314
Yes.... sorry... put "Jpeg.Free;" after the savetostream

procedure TForm1.Button1Click(Sender: TObject);
var
  msSend: TMemoryStream;
  Jpeg: TJPEGImage;
begin
  idClient.Port:=9090;
  idClient.Host:='127.0.0.1';
  idTCpServer1.DefaultPort:=9090;
  idTcpServer1.Active:=True;
  idClient.Connect;
  Jpeg := CaptureScreen;
  msSend := TMemoryStream.Create;
  Jpeg.SaveToStream(msSend); // jpeg.free after the savetostream
  Jpeg.Free; // here
  if idClient.Connected then
  begin
    idClient.WriteLn(IntToStr(msSend.Size));
    idClient.WriteStream(msSend);
  end;
  msSend.Free;
  idClient.Disconnect;
end;

:)

alsantos
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 9623322
Yep, better :-))
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question