Hello All,
I am writing an app in Delphi that takes continuous captures of the client's screen and FTPs them to a server. I have one thread taking the captures and another FTPing them as they are taken. The speed of the captures far surpasses the speed ot the uploads (as one might expect). The ratio is currently something like 3 jpeg uploads for every 50 screen captures. I need to improve my upload rates so that another app can pick up the 'stream' and display them one after another in a reasonable time frame (this app is Flash MX, by the way).
These two functions, while not all-inclusive in terms of my code, represent my current approach:
I am a newbie to Windows-API programming, and especially threads, so I am struggling to make this work efficiently.
Yet another problem I am having is that mouse movement on the client becomes 'choppy' once the capture app is started. In an attempt to allieviate these problems, I started peppering my code with 'Application.ProcessMessages' lines. This seems very inelegant to me - I know there has to be a better solution out there. It gave me some performance gains, but not nearly what I need. I need the same skill that the pros have, where they can have an app working away in the background at some heavy task, with the user oblivious to the action all the while. That's what I am shooting for here. I thought threads would give me that, but so far they haven't. I know FTP is a notoriously slow protocol, but there's gotta be something out there that can speed up my app in that regard as well.
Can anyone help me on this? Any advice/schooling would be much appreciated!
Thanks,
-Tony
I am writing an app in Delphi that takes continuous captures of the client's screen and FTPs them to a server. I have one thread taking the captures and another FTPing them as they are taken. The speed of the captures far surpasses the speed ot the uploads (as one might expect). The ratio is currently something like 3 jpeg uploads for every 50 screen captures. I need to improve my upload rates so that another app can pick up the 'stream' and display them one after another in a reasonable time frame (this app is Flash MX, by the way).
These two functions, while not all-inclusive in terms of my code, represent my current approach:
Code:
function ProcessScreenCaptures(Ptr : Pointer) : LongInt; stdcall;
var
jpeg: TJpegImage;
fileName: string;
x: Integer;
begin
x := 0;
while (KeepProcessing) do
begin
x := x + 1;
fileName := 'screen_' + IntToStr(x) + '.jpg';
jpeg := WindowsScreenCapture;
jpeg.SaveToFile( fileName );
jpeg.Free;
end;
end;
function UploadCaptures(Ptr : Pointer) : LongInt; stdcall;
var
fileName: string;
x: Integer;
begin
x := 0;
while (KeepProcessing) do
begin
MakeFTPConnection();
x := x + 1;
fileName := 'screen_' + IntToStr(x) + '.jpg';
UploadFile( fileName );
CloseFTPConnection();
end;
end;
I am a newbie to Windows-API programming, and especially threads, so I am struggling to make this work efficiently.
Yet another problem I am having is that mouse movement on the client becomes 'choppy' once the capture app is started. In an attempt to allieviate these problems, I started peppering my code with 'Application.ProcessMessages' lines. This seems very inelegant to me - I know there has to be a better solution out there. It gave me some performance gains, but not nearly what I need. I need the same skill that the pros have, where they can have an app working away in the background at some heavy task, with the user oblivious to the action all the while. That's what I am shooting for here. I thought threads would give me that, but so far they haven't. I know FTP is a notoriously slow protocol, but there's gotta be something out there that can speed up my app in that regard as well.
Can anyone help me on this? Any advice/schooling would be much appreciated!
Thanks,
-Tony