Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Remote Screen

Posted on 2003-10-26
9
Medium Priority
?
313 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 2000 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

610 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