Determine command line parameters from invoked Desktop session

brenlex
brenlex used Ask the Experts™
on
I am actually hoping to get feedback from the original contributors to question Q_26726314.  I am attempting to use a C# variation of the ServiceShell class posted by egl1044 -- unfortunately I cannot get this to work with a Delphi application. Please see Q_26917602 for details.

Many thanks.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:

the code goes like that :



 for i:= 0 to paramcount do
    begin
    ///  KEYWORD : debug
    if LowerCase(ParamStr(i)) = 'debug' then

    end;


if it does not work for you :


      *  where do you execute that code ?    form.create ?

      *   can you post a bit of your code to help you on ?

Author

Commented:
Please see Q_26917602 for further info.

Essentially my Delphi app is a long standing application which processes command line parameters OK when firing up normally (from command line, from batch file, from various shell execute methods in other executables etc), however when trying to launch the same Delphi app using the ServiceShell class my paramcount is always 0.  I know I am passing arguments OK from ServiceShell as it works with other apps, such as notepad.

Commented:
made a small demo with shell execute -> working on my computer
------------------------- send parmeters -------------------------------

unit Unit1_xxpas;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ShellApi;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin

        ShellExecute(Handle, nil, 'e:\delphiapp.exe', '/n,/e,    param#1  c:\test\dummy.txt    param#2  c:\\test\\test.txt   parmam#3   anystring??? ', 'c:\temp\', SW_NORMAL);
end;

end.


--------------------------------------------   show cmd parmeters ----------------------

unit Unit_cmdline;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Memo1: TMemo;
    procedure FormShow(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormShow(Sender: TObject);
var  i    : Integer;
begin
   for i:= 0 to paramcount do
      begin

       memo1.lines.add ( LowerCase(ParamStr(i))) ;

      end;
end;

end.

Open in new window

Commented:
see screnn dump for results
ee-cmd-.PNG

Author

Commented:
Awarding points based on BdLm comments in Q_26917602.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial