Log in

View Full Version : Help with Delphi or Lazarus FreePascal


ckmox
16th October 2010, 18:30
so i made a simple GUI encoder for HandbrakeCLI with my limited knowledge on programming but i manage to finished it in a whole day but the problem is that windows 7 users cant seem to run it the command prompt will be active but not gonna do the encoding

i think this is the part (and i bet it is) of the program that is problematic


procedure TfrmMain.btnEncodeClick(Sender: TObject);
var
i: integer;
fullFilename: string;
begin
fullFilename := '';
for i := 0 to lstOut.Items.Count - 1 do
begin
Hbk := Tprocess.Create(nil);
Hbk.CommandLine := extractfilepath(fullFilename) + lstOut.Items[i];
Hbk.Options := Hbk.Options + [poWaitOnExit];
Hbk.Execute;
Hbk.Free;
end;
end;


i already declared Hbk as Tprocess btw on variable declaration part of Lazarus

and could anyone help me how to redirect the command prompt activities to the program itself maybe a progress bar will do so any help on this will be appreciated too

thanks for reading waiting for reply
if you want to test it out on your windows 7 too here it is
http://www.mediafire.com/?a3tuf6sbbrrbbyd
i included the recent HandbrakeCLI with it too

P.S. in on windows xp sp3 and Lazarus 0.9.28.2

EDIT:

i manage to make a ProgressBar but i think the problem on windows 7 remains here is the updated program http://www.mediafire.com/?x7emm2d1wvvyoyq

LoRd_MuldeR
17th October 2010, 11:51
I don't know what a TProcess is in your program. Not a Delphi standard class, as far as I know.

Here is my own code for creating and managing processes in my Delphi applications, including stdout/stderr redirection and job control:
http://code.google.com/p/mulder/source/browse/trunk/LameXP/src/Unit_RunProcess.pas

It's based on this MSDN article:
http://support.microsoft.com/kb/190351/en-us

ckmox
17th October 2010, 14:27
thanks Lord Mulder ill check it out and it seems ive fix the problem now it turns out when running the HandbrakeCLI with Tprocess on long filenames it should be in doubel quotes so i did that on input files and output files of HandbrakeCLI and now its working

here is the finished product (for now) -> http://www.mediafire.com/?a43fbe178o9035n

LoRd_MuldeR
17th October 2010, 15:01
thanks Lord Mulder ill check it out and it seems ive fix the problem now it turns out when running the HandbrakeCLI with Tprocess on long filenames it should be in doubel quotes so i did that on input files and output files of HandbrakeCLI and now its working

When passing command-line arguments to an application, all argument strings that contain (or may contain) whitespace characters must always be enclosed in double quotes. That's because on the command-line whitespace characters are interpreted as argument separators and thus cannot occur within the individual argument string - unless the whole argument string is put into quotes.

(However in my experience it sometimes is better to pass "short" 8+3 filenames, because some CLI tools don't handle Unicode filenames correctly)

ckmox
19th October 2010, 14:53
When passing command-line arguments to an application, all argument strings that contain (or may contain) whitespace characters must always be enclosed in double quotes. That's because on the command-line whitespace characters are interpreted as argument separators and thus cannot occur within the individual argument string - unless the whole argument string is put into quotes.

(However in my experience it sometimes is better to pass "short" 8+3 filenames, because some CLI tools don't handle Unicode filenames correctly)

thanks for the tips Lord Mulder ill keep those in mind

roozhou
20th October 2010, 13:58
(However in my experience it sometimes is better to pass "short" 8+3 filenames, because some CLI tools don't handle Unicode filenames correctly)
It doesn't matter whether the tool use CLI or GUI. A lot of GUI apps fail to handle unicode filenames as well.

AFAIK Delphi 2010 is first version that supports unicode natively. MinGW does not native supports wmain(), you have to use Windows native API GetCommandLineW to get the args in unicode. Since most projects using MinGW are cross-platform, they don't support unicode(e.g. x264 and MPlayer).

If your tool doesn't support unicode filenames, you can use GetShortPathNameW to get the 8.3 filename in unicode and
use WideCharToMultiByte to convert unicode to ascii.