المشاركات : 19
المواضيع 14
:
: 0
الإنتساب : May 2010
السلام عيكم ورحمة الله تعالى وبر كاته
كيف يتم التقاط صورة لسطح المكتب بالسرفر وارسالها الى client ؟
المشاركات : 17
المواضيع 1
:
: 0
الإنتساب : Dec 2008
كود :
procedure TMainFormClient.TimerTimer(Sender: TObject);
var
JpegStream : TMemoryStream;
pic : TBitmap;
sCommand : string;
begin
if not TCPClient.Connected then Exit;
Timer.Enabled := False;
TCPClient.WriteLn('CheckMe');
sCommand := TCPClient.ReadLn;
if sCommand = 'TakeShot' then
begin
pic := TBitmap.Create;
JpegStream := TMemoryStream.Create;
ScreenShot(0,0,Screen.Width,Screen.Height,pic);
BMPtoJPGStream(pic, JpegStream);
pic.FreeImage;
FreeAndNil(pic);
// copy file stream to write stream
TCPClient.WriteInteger(JpegStream.Size); // first send the size
TCPClient.OpenWriteBuffer;
TCPClient.WriteStream(JpegStream); //then send the image
TCPClient.CloseWriteBuffer;
FreeAndNil(JpegStream);
//making sure!
sCommand := TCPClient.ReadLn;
end;
Timer.Enabled := True;
end;
كود :
procedure TMainFormServer.TCPServerExecute(AThread: TIdPeerThread);
var
Client : PClient;
Command : string;
Size : integer;
PicturePathName : string;
ftmpStream : TFileStream;
begin
if not AThread.Terminated and AThread.Connection.Connected then
begin
Client := PClient(AThread.Data);
Client.LastAction := Now;
Command := AThread.Connection.ReadLn;
if Command = 'CheckMe' then
begin
if Client.TakeShot = True then
begin
Client.TakeShot := False;
AThread.Connection.WriteLn('TakeShot');
PicturePathName := ExtractFileDir(ParamStr(0)) +
'\' + Client.HostName + '_Screen.JPG';
if FileExists (PicturePathName) then DeleteFile(PicturePathName);
ftmpStream := TFileStream.Create(PicturePathName,fmCreate);
Size := AThread.Connection.ReadInteger;
AThread.Connection.ReadStream(fTmpStream,Size,False);
FreeAndNil(fTmpStream);
AThread.Connection.WriteLn('DONE');
end
else
AThread.Connection.WriteLn('DONE');
end;
end;
end;
المصدر
كود :
http://delphi.about.com/od/internetintranet/l/aa012004a.htm