Home > other >  Is it possible to pass parameters from a batch file to delphi?
Is it possible to pass parameters from a batch file to delphi?

Time:09-17

I already know, that I can run an exe with parameters like so:

@echo off
cd C:\Users\Superuser\Documents
executable.exe -myparamater

But I can't figure out how I could recieve this parameter in delpi. My goal is to simply print the parameter. Does anybody have an idea how I could do this? I appreciate any help, sheers!

// Catch parameter here
WriteLn(parameter);

Note: My program is a simple console program made in delphi.

CodePudding user response:

You may use the ParamCount and ParamStr functions:

procedure TForm1.Button1Click(Sender: TObject);
var
  j: Integer;
begin

   for j := 1 to ParamCount do
     ShowMessage(ParamStr(j));

end;
  • Related