Hi All,
I am writing a procedure called OpenHTMLFile. It works fine with
HTML_Browser_file (which is the command to run) set to 'firefox' on my
Linux Ubuntu 10.04 system.
My question is this... what do I need to change to make
HTML_Browser_file default to the default application (path and filename)
to open a html file e.g. I want it to be the path and application
filename of ANY computer's HTML browser. I assume that in this day of
modern computing that it would be safe to assume that the user has some
kind of html browsing software whether it be: Firefox, Chrome, Internet
Explorer, or whatever it is that Macs use ... sorry for my ignorance,
but I am not a Mac user, so I am no up with the latest browser for Macs.
I want to do this:
Proc.CommandLine := HTML_Browser_file;
// e.g. it will now be 'firefox'
if Proc.CommandLine is a valid application then
Proc.CommandLine := Whatever_is_the_default_HTML_Browser;
>From Memo1 after run of project1 and call to Button1Click:
File HTML_2_Open "test1.html" does not exists. Opening browser with
blank filename.
Process.CommandLine is: "firefox"
uses Process;
[...]
procedure TForm1.OpenHTMLFile(HTML_Browser_file, HTML_2_Open : String);
var
x : integer;
Proc : TProcess;
S : String;
I : integer;
begin
{ // this code not used!!!
S := Application.ExeName;
// hack for Mac
I := Pos('.app/Contents/MacOS/', S);
if (I > 0) then
S := Copy(S,1, I+3);
}
Proc := TProcess.Create(nil);
try
// Proc.CommandLine := '/Applications/MyApp.app';
Proc.CommandLine := HTML_Browser_file;
if not fileExists( HTML_2_Open ) then
begin
memo1.lines.add( 'File HTML_2_Open "' + HTML_2_Open + '" does not
exists. Opening browser with blank filename.' );
HTML_2_Open := '';
end
else
Proc.CommandLine := Proc.CommandLine + ' ' + HTML_2_Open;
memo1.lines.add( 'Process.CommandLine is: "' + Proc.CommandLine +
'"');
PRoc.Options := Proc.Options + [poWaitOnExit];
Proc.CommandLine := Proc.CommandLine;
PRoc.Execute;
finally
Proc.free;
end;
end; { OpenHTMLFile }
{---------------------------------------------------------}
procedure TForm1.Button1Click(Sender: TObject);
const
Default_HTML_Browser_file = 'firefox';
var
HTML_Browser_file, HTML_2_Open : String;
begin
HTML_Browser_file := Default_HTML_Browser_file;
HTML_2_Open := 'test1.html';
OpenHTMLFile(HTML_Browser_file, HTML_2_Open);
end;
Best Regards,
PEW
Hobart, Tasmania, Australia
--
Proudly developing Quality Cross Platform Open Source Games
Since 1970 with a Commodore PET 4016 with 16 KRAM
http://pews-freeware-games.org (<--- brand new)
--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus