Re: Howcan I make a program that have some COMMAND LINE options.

Posted by John Doe on January 17, 2003

In Reply to: Re: Howcan I make a program with COMMAND LINE options. posted by webmaster Guido on October 18, 2002

This seem to work 'pretty' well, I made this dirty hack for a win2k box while I was writing a simple editor. The idea was to open multiple files at once with this 'right-click' registry entry

[HKEY_CLASSES_ROOT\*\shell\MyProgram\Command]
@ = "MyProgram.exe %1"

and this is the snippet that made it happen

procedure TfrmMain.FormShow(Sender: TObject);
var
 i: integer;
begin
  {Check to see if we need to load files from commandline}
  if ParamCount > 0 then
    for i := 1 to ParamCount do begin
      if FileExists(ParamStr(i)) then
        OpenFile(ParamStr(i));
    end
  else
    FileNew.Execute;
end;

Pretty self-explanetory ey? I later had some headaches with opening multiple files succcessfully BUT with a cryptic exception when I closed the program. It may have been due to some other bug however.


Related Articles and Replies:


Find related articles

Suggested keywords:
  command line,  pass parameters,  application parameters,  shellexecute



[ Related Articles and Replies ] [ DelphiLand Discussion Forum ]