Displaying Desktop Client with Delphi

I'm not yet recently updating this blog for couple days since there’s lots of jobs I have done in a while. I am focused about how to make a small part of remote desktop module over Delphi for my current project indeed, some kind like Terminal Service Client or Virtual Network Computing (VNC). And overall, it was taking too much time but I did it.

I had collected information from various sources to solve this problem, started from delphi specific mailing list until joined an international channel on IRC (#delphi). While few numbers gave some interesting clues, there are rumors about non-existence add in components to make it done instantly. But you could do this over Delphi native component provided mixed in by your own logic exactly.

So, what is the native components? Some said that the connection socket can easily created under Indy tab components, while others said it can be done with Internet tab components. Well, both above are commonly supported since it should use TCP and UDP link to do so. No big deal with these, but I’m trying to create it under Internet tabs components. Currently, i'm using TClientSocket and TServerSocket component. The scenario is as simple as grabing the host desktop image and send it over this socket connection. Then refreshing the pictures periodically as you might seen on server side monitor.



First of all, you have to initialized the type of the client status:

type
TCliStatusWatch=(csLihat,csGambar);

And from the TClientSocket onRead event, make a validation to process the type of the connections:

case CliStatusWatch of
csLihat:
begin
Socket.ReceiveBuf (Buffer, 5);
strIn:=Copy (Buffer,1,5);
if strIn = 'BITM!' then CliStatusWatch:=csGambar
end;

csGambar:
begin
s:=Socket.ReceiveText;
if not Reciving then
begin
if send=true then
begin
SetLength(sl, StrLen(PChar(s))+1);
StrLCopy(@sl[1], PChar(s), Length(sl)-1);
DataSize:= StrToIntDef(sl,0);
Data:= TMemoryStream.Create;
Delete(s, 1, Length(sl));
FBmp.progressbar1.min:=0;
FBmp.progressbar1.max:=DataSize;
Reciving:= true;
end;
end;
try
if send=true then
begin
Data.Write(s[1], length(s));
Caption:='Downloading image...';
end;
if reciving=true then FBmp.progressbar1.Position:=Data.Size;
if (Data.Size = DataSize) then
begin
Caption:='Displaying remote screen.';
Bmp := TBitmap.Create;
Jpg := TJpegImage.Create;
Data.Position:= 0;
Jpg.LoadFromStream(Data);
if data.size<>0 then FBmp.Image1.Picture.Assign(Jpg);
reciving:=false;
Jpg.Free;
Bmp.FreeImage;
end;
if (reciving=false) and (send=true) then
begin
cliStatusWatch:=csLihat;
Socket.SendText('BITM!');
Caption:='Capturing remote screen.';
end
else if (reciving=false) and (send=false) then
begin
FBmp.Timer1.Enabled:=false;
cliStatusWatch:=csLihat;
end;
except
Bmp.Free;
Jpg.Free;
Data.Free;
end;
end;

end;

Also, you may need to find scktcomp.pas over the internet which provided by Borland as a visual component library unit for Windows socket components and use it as external add-in unit.



The scratched source above are very limited. If you are in hurry to find out the complete codes, click link image below and make a US$10 money transfer over my existing PayPal account. After I get an email notification, I’ll confirmed you & send the codes as an email attachment.








PS: If you've benefit from this blog,
you can support it by making a small contribution.

Enter your email address to receive feed update from this blog:

Post a Comment

 

Post a Comment

Leave comments here...